How the curl to Go conversion works
The URL and method become an http.NewRequest call, each -H flag becomes a req.Header.Set line, -d becomes a strings.NewReader body, -u becomes req.SetBasicAuth, and -k produces a client with InsecureSkipVerify.
Example
curl https://api.example.com/status -H 'Accept: application/json'
becomes:
package main
import (
"fmt
"io
"net/http"
)
func main() {
req, err := http.NewRequest(http.MethodGet, "https://api.example.com/status", nil)
if err != nil {
panic(err)
}
req.Header.Set("Accept", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
b, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode)
fmt.Println(string(b))
}