package main import ( "bytes" "fmt" "os" ) func main() { var buf bytes.Buffer buf.WriteString("Hello, Go!") buf.WriteTo(os.Stdout) }
package main import ( "bytes" "fmt" "net/http" ) func main() { var buf bytes.Buffer buf.WriteString("Hello, Go!") req, _ := http.NewRequest("POST", "http://www.example.com", &buf) req.Write(os.Stdout) }In this example, we create a buffer, write some string content to it and then create an HTTP POST request using `http.NewRequest`. We pass the buffer as the request body and then call `Write` method to write the request to the console. Overall, `bytes` is a package library in Go which provides low-level manipulation of byte slices and buffer operations. The `WriteTo` method is a convenient way to write the contents of a buffer to an interface that implements the `io.Writer` interface.