O'Reilly logo

Go Standard Library Cookbook by Radomir Sohlich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

The net package contains the Interfaces function, which lists the network interfaces as a slice of the Interface struct. The Interface struct has the Addrs method, which lists the available network addresses. This way, you can list the addresses by their interfaces.

Another option is to use the InterfaceAddrs function of the net package, which provides the slice of structs that implement the Addr interface. This provides you with methods to obtain the information you want.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required