MCPcopy Create free account
hub / github.com/PostHog/duckgres / freeLocalPort

Function freeLocalPort

controlplane/admin/devserver/main.go:172–179  ·  view source on GitHub ↗

freeLocalPort returns an unused localhost TCP port.

()

Source from the content-addressed store, hash-verified

170 cmd.Stdout, cmd.Stderr = os.Stderr, os.Stderr
171 if err := cmd.Start(); err != nil {
172 log.Fatalf("start port-forward: %v", err)
173 }
174 return cmd
175}
176
177// freeLocalPort returns an unused localhost TCP port.
178func freeLocalPort() (int, error) {
179 l, err := netlisten.Listen("tcp", "127.0.0.1:0")
180 if err != nil {
181 return 0, err
182 }

Callers 1

mainFunction · 0.85

Calls 2

AddrMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected