I'm writing a simple UDP server, and I'm trying to use the new net/netip
data types.  My main loop starts as follows:

    for {
        n, a, err := sock.ReadFrom(buf)
        if err != nil {
            log.Printf("ReadFrom: %v", err)
            time.Sleep(100 * time.Millisecond)
            continue
        }
        aa, ok := a.(*net.UDPAddr)
        if !ok {
            log.Println("not a UDP address (this shouldn't happen)")
            continue
        }
        ip, ok := netip.AddrFromSlice(aa.IP)
        if !ok {
            log.Println("AddrFromSlice not ok")
            continue
        }
        ip = ip.Unmap()
        addr := netip.AddrPortFrom(ip, uint16(aa.Port))

That seems extremely verbose.  Am I doing something wrong?

-- Juliusz

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/878rjrbb07.fsf%40pirx.irif.fr.

Reply via email to