MCPcopy Index your code
hub / github.com/perkeep/perkeep / Localhost

Function Localhost

internal/netutil/netutil.go:103–111  ·  view source on GitHub ↗

Localhost returns the first address found when doing a lookup of "localhost". If not successful, it looks for an ip on the loopback interfaces.

()

Source from the content-addressed store, hash-verified

101// doing a lookup of "localhost". If not successful,
102// it looks for an ip on the loopback interfaces.
103func Localhost() (net.IP, error) {
104 if ip := localhostLookup(); ip != nil {
105 return ip, nil
106 }
107 if ip := loopbackIP(); ip != nil {
108 return ip, nil
109 }
110 return nil, errors.New("no loopback ip found")
111}
112
113// localhostLookup looks for a loopback IP by resolving localhost.
114func localhostLookup() net.IP {

Callers 2

TestLocalhostFunction · 0.70
ListenOnLocalRandomPortFunction · 0.70

Calls 2

localhostLookupFunction · 0.85
loopbackIPFunction · 0.85

Tested by 1

TestLocalhostFunction · 0.56