package main import ( "fmt" "net" ) func main() { conn, err := net.Dial("tcp", "example.com:80") if err != nil { fmt.Println("Error:", err) return } // Close the write side of the TCP connection conn.(*net.TCPConn).CloseWrite() // Attempt to write to the connection now creates an error _, err = conn.Write([]byte("Hello, world!")) if err != nil { fmt.Println("Error:", err) return } }In this example, we dial a TCP connection to `example.com` on port `80`. We then use a type assertion to convert the `net.Conn` interface to a `net.TCPConn` so we can use the `CloseWrite` method. We call `CloseWrite` to close the write side of the connection, and then attempt to write to the connection again. This causes an error because the write side of the connection has been closed. The `net` package is the library used for this example.