title: golang distinguish IPv4 IPv6
body: <p>For a program I'm working on, I have to check whether an IP (the IP which connects me to the Internet) is public or private. For that, I need to distinguish if an IP is IPv4 or IPv6. </p>
  
  <p>I wanted to check it by the length of the IP: </p>
  
  <pre><code>conn, err := net.Dial("udp", "8.9.10.11:2342")
  if err != nil {
      fmt.Println("Error", err)
  }
  
  localaddr := conn.LocalAddr()
  
  addr, _ := net.ResolveUDPAddr("udp", localaddr.String())
  
  ip := addr.IP
  
  fmt.Println(ip)
  fmt.Println(len(ip))
  </code></pre>
  
  <p>Well, my IP is 192.168.2.100, so IPv4, but len(ip) tells me that the length is 16 which would be IPv6. 
  What is my mistake? Does any other method exist to distinguish between IPv4 and IPv6 which works always?</p>