十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
import "net"
func Ips() (map[string]string, error) {
ips := make(map[string]string)
interfaces, err := net.Interfaces()
if err != nil {
return nil, err
}
for _, i := range interfaces {
byName, err := net.InterfaceByName(i.Name)
if err != nil {
return nil, err
}
addresses, err := byName.Addrs()
for _, v := range addresses {
ips[byName.Name] = v.String()
}
}
return ips, nil
}