Tutorial by Examples

Perform a basic GET request and prints the contents of a site (HTML). package main import ( "fmt" "io/ioutil" "net/http" ) func main() { resp, err := http.Get("https://example.com/") if err != nil { panic(err) } ...
A request for the top 10 most recently active StackOverflow posts using the Stack Exchange API. package main import ( "encoding/json" "fmt" "net/http" "net/url" ) const apiURL = "https://api.stackexchange.com/2.2/posts?" ...
1.7+ Timing out an HTTP request with a context can be accomplished with only the standard library (not the subrepos) in 1.7+: import ( "context" "net/http" "time" ) req, err := http.NewRequest("GET", `https://example.net`, nil) ctx, _ := ...
The following updates a User object via a PUT request and prints the status code of the request: package main import ( "bytes" "encoding/json" "fmt" "net/http" ) type User struct { Name string Email string } func main...

Page 1 of 1