You can create an http request with a custom header in go using the net/http
package. Here's an example code snippet:
main.go395 chars24 lines
In the code above, we create a new http.Request
object with the NewRequest
function and set the HTTP method to "GET"
and the URL to "https://example.com/api"
. Then, we set a custom header with the Header.Set
method. Finally, we make the HTTP request using an http.Client
object and read the response body.
gistlibby LogSnag