This tool turns a curl command into Go code. (To do the reverse, check out sethgrid/gencurl.) Currently, it knows the following options: -d/--data, -H/--header, -I/--head, -u/--user, --url, and -X/--request. It also understands JSON content types (see JSON-to-Go). Feel free to contribute on GitHub!
Note: http.DefaultClient will follow redirects by default, whereas curl does not without the --location
flag. Since reusing HTTP client is good Go practice, this tool does not attempt to configure the HTTP client for you.