cURL to Go
Paste a curl command and get Go code using net/http — or pick any other language.
Paste a curl command above to generate code
How curl maps to Go (net/http)
- →Uses only the standard library: http.NewRequest, req.Header.Set and http.DefaultClient.
- →The body is wrapped in strings.NewReader; for large or streamed bodies use an io.Reader of your own.
- →Set a timeout in production: http.DefaultClient has none — create &http.Client{Timeout: 10 * time.Second}.
Frequently asked
How do I convert a curl command to Go?
Paste it and pick Go (net/http). You get a complete main package that builds the request, sets every header and prints the status and body.
Why add a timeout to the Go client?
http.DefaultClient waits forever. A stuck server would hang your program, so production code should always use a client with a Timeout.