Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindAvailablePort ¶
func FindAvailablePort(checker PortChecker, startPort int, maxAttempts int) int
FindAvailablePort finds the first available port starting from startPort. It searches up to maxAttempts ports.
func ResetCache ¶
func ResetCache()
ResetCache clears the port availability cache. Used for testing.
Types ¶
type MockPortChecker ¶
MockPortChecker is a test implementation that can be configured.
func (MockPortChecker) IsAvailable ¶
func (m MockPortChecker) IsAvailable(port int) bool
type PortChecker ¶
PortChecker defines the interface for checking port availability.
type RealPortChecker ¶
type RealPortChecker struct{}
RealPortChecker uses net.Listen to check port availability.
func (RealPortChecker) IsAvailable ¶
func (RealPortChecker) IsAvailable(port int) bool
IsAvailable checks if a TCP port is available on localhost. It uses net.Listen to attempt binding to the port.
Click to show internal directories.
Click to hide internal directories.