packagemain import( "fmt" "net" "strings" ) funcmain(){ conn,err:=net.Dial("udp","google.com:80") iferr!=nil{ fmt.Println(err.Error()) return } deferconn.Close() fmt.Println(strings.Split(conn.LocalAddr().String(),":")[0]) }原文链接:https://www.f2er.com/go/190607.html