Set HTTP request headers in Go by calling the Header.Set method on the Request object before executing the request.
Use the Header.Set method on the Request object to add or update headers before sending the request.
req, _ := http.NewRequest("GET", "https://example.com", nil)
req.Header.Set("Authorization", "Bearer token123")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
Headers are like the envelope on a letter, carrying instructions about the message rather than the message itself. You set them to tell the server who you are, what format you want, or what data you are sending. This ensures the server processes your request correctly.