curl-to-Go

Instantly convert curl commands to Go code

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!

Example 1 · Example 2 · Example 3 · Example 4 · Example 5

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.