addr, err := net.ResolveTCPAddr("tcp", "127.0.0.1:8080") if err != nil { // handle error }
fmt.Println("IP address:", addr.IP) fmt.Println("Port:", addr.Port)
listener, err := net.ListenTCP("tcp", addr) if err != nil { // handle error } defer listener.Close()This code creates a net.Listener object that listens for incoming TCP connections on the specified TCPAddr. The net package is the standard library package for networking in Go.