port

package
v0.10.9 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2025 License: GPL-3.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// FlagName is the name of the port flag.
	FlagName = "port"

	// FlagUsage is the usage of the port flag. It describes allowed values and the default port.
	FlagUsage = "Specify the port number for the server."
)

Variables

View Source
var (
	ErrNilPortFlag = errors.New("port flag cannot be nil")
)

Functions

func SetFlag

func SetFlag(flag *Flag)

SetFlag initializes the port flag.

Types

type Flag

type Flag struct {
	goflags.Flag
}

Flag is a custom flag type for port, embedding goflags.Flag.

func NewFlag

func NewFlag(
	defaultValue *string,
) *Flag

NewFlag creates a new Flag with allowed values.

Parameters:

defaultValue - the default value for the flag.

Returns:

A pointer to the created Flag.

func (*Flag) Default

func (f *Flag) Default() string

Default returns the default value of the flag.

Returns:

The default value.

func (*Flag) Port added in v0.10.3

func (f *Flag) Port() (int, error)

Port returns the current port value.

Returns:

The port number as an integer, or an error if conversion fails.

Jump to

Keyboard shortcuts

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