July 2019
Intermediate to advanced
458 pages
12h 12m
English
The package exposes a http.Client type that can be used to make requests. If the requests are simple GET or POST, then there are dedicated methods. The package also offers a function with the same name, but it's just a shorthand to the respective methods for the DefaultClient instance. Check the following code:
resp, err := http.Get("http://example.com/")resp, err := client.Get("http://example.com/")...resp, err := http.Post("http://example.com/upload", "image/jpeg", &buf)resp, err := client.Post("http://example.com/upload", "image/jpeg", &buf)...values := url.Values{"key": {"Value"}, "id": {"123"}}resp, err := http.PostForm("http://example.com/form", values)resp, err := client.PostForm("http://example.com/form", values) ...Read now
Unlock full access