title: How to get IP and Port from net.Addr when it could be a net.UDPAddr or net.TCPAddr
body: <p>I'm running a hybrid server which listens on both TCP and UDP and need to get the local port, remote IP address and remote port. Currently the way I'm checking if the underlying type is net.UDPAddr or a net.TCPAddr is the following:</p>
  
  <pre><code>// BAD: but not sure a better way
  switch reflect.TypeOf(remoteAddr).String() {
  case "*net.UDPAddr":
      p.SrcIP = remoteAddr.(*net.UDPAddr).IP.String()
      p.SrcPort = uint(remoteAddr.(*net.UDPAddr).Port)
      p.DstPort = uint(localAddr.(*net.UDPAddr).Port)
  case "*net.TCPAddr":
      p.SrcIP = remoteAddr.(*net.TCPAddr).IP.String()
      p.SrcPort = uint(remoteAddr.(*net.TCPAddr).Port)
      p.DstPort = uint(localAddr.(*net.TCPAddr).Port)
  }
  </code></pre>
  
  <p>I'm not the greatest fan of this, if anyone has any cleaner looking solutions that would be greatly appreciated </p>