MCPcopy Create free account
hub / github.com/MertJSX/folderhost / GetLocalIPs

Function GetLocalIPs

utils/get_local_ips.go:5–22  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import "net"
4
5func GetLocalIPs() []string {
6 var ips []string
7
8 addrs, err := net.InterfaceAddrs()
9 if err != nil {
10 return ips
11 }
12
13 for _, addr := range addrs {
14 if ipNet, ok := addr.(*net.IPNet); ok && !ipNet.IP.IsLoopback() {
15 if ipNet.IP.To4() != nil {
16 ips = append(ips, ipNet.IP.String())
17 }
18 }
19 }
20
21 return ips
22}

Callers 1

mainFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected