MCPcopy Index your code
hub / github.com/golang/groupcache / pickFreeAddr

Function pickFreeAddr

http_test.go:133–140  ·  view source on GitHub ↗

This is racy. Another process could swoop in and steal the port between the call to this function and the next listen call. Should be okay though. The proper way would be to pass the l.File() as ExtraFiles to the child process, and then close your copy once the child starts.

(t *testing.T)

Source from the content-addressed store, hash-verified

131// The proper way would be to pass the l.File() as ExtraFiles to the child
132// process, and then close your copy once the child starts.
133func pickFreeAddr(t *testing.T) string {
134 l, err := net.Listen("tcp", "127.0.0.1:0")
135 if err != nil {
136 t.Fatal(err)
137 }
138 defer l.Close()
139 return l.Addr().String()
140}
141
142func addrToURL(addr []string) []string {
143 url := make([]string, len(addr))

Callers 1

TestHTTPPoolFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…