SSL certificate error in Go

Self-signed or expired certs will break in strict clients even though -k made curl happy. Paste your curl command to see what Go (net/http) would send and compare against the working request.

Quick answer

To convert a cURL command to Go, paste it into the Toolpaper workbench below. It parses the command in your browser and emits idiomatic Go code — headers, query string, request body, authentication (Bearer, Basic, API key), and cookies are all wired up automatically. No data is uploaded; conversion is fully client-side.

Prefer a different target? See the full cURL to Go reference, or jump to the same guide in JavaScript, Node.js, or Python.

InputcURL command
1 secret
MethodGET·Headers1·Body—· Chars 73
OutputGo · net/http(stdlib)
package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    client := &http.Client{CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }}
    req, _ := http.NewRequest("GET", "https://api.example.com/me", nil)
    req.Header.Set("Authorization", "Bearer YOUR_TOKEN")
    resp, err := client.Do(req)
    if err != nil { panic(err) }
    defer resp.Body.Close()
    out, _ := io.ReadAll(resp.Body)
    fmt.Println(string(out))
}
Inspect

Example

A representative curl command for this scenario. Paste your own above to convert an exact match.

curl input
curl https://api.example.com/me \
  -H "Authorization: Bearer YOUR_TOKEN"

Implementation notes

  • Fix the certificate, or configure the language client with a custom CA bundle. Never disable verification in production.
  • Use the Explain panel to enumerate exactly which headers, cookies, and TLS flags the curl request carries.
  • The In-browser Runner is a fast way to confirm whether the failure reproduces from the browser or only from the server.

Common mistakes

  • Comparing curl and Go without capturing both actual wire requests — mitmproxy or Charles pays off here.
  • Assuming a working curl means the API is happy — client differences (redirect handling, keep-alive, HTTP/2) surface as edge cases.
  • Silencing warnings instead of fixing them — every Go client has a way to log the outgoing request; turn it on.

Common questions

Why does curl work but Go fail?
Usually a header curl adds by default is missing in Go, or vice versa. Paste the curl above to see a normalized breakdown.
Is my request sent to Toolpaper?
No. Parsing and diffing run in your browser.

More guides in Go

Go hub →

The same guide in other languages

All guides →

Full Go reference on the cURL to Go hub, or open the main converter for all 18 targets.