HTTP client
Context
Section titled “Context”The net/http package provides an HTTP client. Use http.Get for simple GET requests, or http.Client for custom timeouts, headers, etc.
Example
Section titled “Example”Fetch a URL and print the status code.
Code example
Section titled “Code example”package main
import ( "fmt" "net/http" "time")
func main() { client := &http.Client{Timeout: 5 * time.Second} resp, err := client.Get("https://example.com") if err != nil { fmt.Println("Error:", err) return } defer resp.Body.Close() fmt.Println("Status:", resp.Status)}Output
Section titled “Output”Status: 200 OK