networking

package
v0.0.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyPort      = errors.New("port cannot be empty")
	ErrInvalidFormat  = errors.New("invalid port format")
	ErrPortOutOfRange = errors.New("port number must be between 1 and 65535")
)

Common port validation errors

Functions

func GetRandomListeningPort added in v0.0.5

func GetRandomListeningPort(tb testing.TB) string

GetRandomListeningPort finds an available port for a test by binding to port 0, and returns a string like localhost:PORT

func GetRandomPort added in v0.0.5

func GetRandomPort(tb testing.TB) int

GetRandomPort finds an available port for a test by binding to port 0

func ValidatePort

func ValidatePort(portStr string) (string, error)

ValidatePort checks if the provided port string is valid and returns a normalized version. It accepts formats like ":8080", "localhost:8080", "127.0.0.1:8080", or "8080". Returns the normalized port format (":PORT") and an error if the port is invalid.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL