ipport.go 315 B

12345678910111213141516171819
  1. package missinggo
  2. import (
  3. "net"
  4. "strconv"
  5. )
  6. type IpPort struct {
  7. IP net.IP
  8. Port uint16
  9. }
  10. func (me IpPort) String() string {
  11. return net.JoinHostPort(me.IP.String(), strconv.FormatUint(uint64(me.Port), 10))
  12. }
  13. func IpPortFromNetAddr(na net.Addr) IpPort {
  14. return IpPort{AddrIP(na), uint16(AddrPort(na))}
  15. }