Standard library / net

net.TCPAddr

Address structure for tcp endpoints, with IP, port and optional IPv6 zone. Expected stdout: '80\n'.

Formal Syntax & Structure

go syntaxgo
type TCPAddr struct {  IP   IP  Port int  Zone string}

Working Example

Example Snippetgo
package main
import (  "fmt"  "net")
func main() { v := &net.TCPAddr{IP: net.IPv4(192, 0, 2, 7), Port: 80}; fmt.Println(v.Port) }
func must[T any](v T, e error) T {  if e != nil {    panic(e)  }  return v}func check(e error) {  if e != nil {    panic(e)  }}
Go Reference