package main import ( "fmt" "net" ) func main() { listener, err := net.Listen("tcp", ":8080") if err != nil { panic(err) } fmt.Printf("Listening on %s", listener.Addr().String()) // rest of your code here }In this example, we create a TCP listener on port 8080 using the net.Listen function. We then print out the address of the listener using the Addr method. Package library: net package in Go standard library.