req, err := http.NewRequest("GET", "https://example.com", nil) if err != nil { log.Fatal(err) } req.Header.Set("Accept-Encoding", "gzip") if req.ProtoMinor == 1 { req.Header.Set("Connection", "keep-alive") }In this example, we create a new HTTP request with the GET method and set the target URL to https://example.com. We then set the Accept-Encoding header to gzip to indicate that the client can handle compressed responses. We also check the ProtoMinor field to see if the request is using HTTP/1.1 and set the Connection header to keep-alive if it is. The net/http package is the package library used in this example.