Here is an example code that makes an HTTP request with a custom binary body and returns a binary response using Go's built-in net/http package:
main.go725 chars36 linesIn this example, the binary data is stored in the data variable as a byte slice. We create a new POST request to url with the data as the request body using bytes.NewBuffer(data).
We add a Content-Type header with the value of application/octet-stream to indicate that the data is binary.
We then create a new http.Client and send the request with client.Do(req). When the response is received, we read the binary response body using ioutil.ReadAll(resp.Body). Finally, we print the response body to the console with fmt.Println("Response body:", body).
gistlibby LogSnag