Skip to content

net: re-implement Interfaces and InterfaceAddrs for IPNet, IPv6 on Windows #5395

@gopherbot

Description

@gopherbot

by [email protected]:

The following code returns different results based on the platform:

package main

import (
    "fmt"
    "net"
)

func main() {
    addrs, _ := net.InterfaceAddrs()
    for _, addr := range addrs {
        fmt.Println(addr.String())
    }
}

On Linux it produces:

127.0.0.1/8
192.168.1.10/24
::1/128
fe80::21b:21ff:fe14:3bd3/64

On Windows it produces:

192.168.11.71

0.0.0.0

192.168.1.107

192.168.56.1

Please note the lack of CIDR netmasks


What is the expected output?
Consistent output no matter which platform. I think that including the CIDR is a better
option (Linux has it right, Windows has it wrong)


What do you see instead?
Linux includes the CIDR with the address. Windows omits the CIDR notation.


Which compiler are you using (5g, 6g, 8g, gccgo)?
6g on both platforms


Which operating system are you using?
Linux and Windows


Which version are you using?  (run 'go version')
Windows is 1.1rc1 (also tested with 1.0.2 with the same results), Linux 1.0.3


Please provide any additional information below.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions