goparam

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: MIT Imports: 6 Imported by: 0

README

goparam

Param is a wrapper of the standard flag package which adds a support of environment variables.

It is very simular to flag, but expects yet another parameter (environment variable name).

Example:

// flag
myParam := flag.String("my-param", "default value", "Description")

// param
myParam := param.String("MY_PARAM", "my-param", "default value", "Description")

It support Parse and PrintDefaults functions too.

Available types: bool, int, int64, uint, uint64, float64, time.Duration, string.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(envName string, paramName string, defaultValue bool, description string) *bool

Bool defines a bool parameter with specified parameter name, environment variable name, default value, and usage string. The return value is the address of a bool variable that stores the value of the flag or the enviroment variable.

func Duration

func Duration(envName string, paramName string, defaultValue time.Duration, description string) *time.Duration

Duration defines a time.Duration parameter with specified parameter name, environment variable name, default value, and usage string. The return value is the address of a time.Durarion variable that stores the value of the flag or the enviroment variable.

func Float64

func Float64(envName string, paramName string, defaultValue float64, description string) *float64

Float64 defines a float64 parameter with specified parameter name, environment variable name, default value, and usage string. The return value is the address of a float64 variable that stores the value of the flag or the enviroment variable.

func Int

func Int(envName string, paramName string, defaultValue int, description string) *int

Int defines an int parameter with specified parameter name, environment variable name, default value, and usage string. The return value is the address of an int variable that stores the value of the flag or the enviroment variable.

func Int64

func Int64(envName string, paramName string, defaultValue int64, description string) *int64

Int64 defines an int64 parameter with specified parameter name, environment variable name, default value, and usage string. The return value is the address of an int64 variable that stores the value of the flag or the enviroment variable.

func Parse

func Parse()

Parse parses the command-line flags from os.Args[1:].

func PrintDefaults

func PrintDefaults()

PrintDefaults prints, to standard error unless configured otherwise, a usage message showing the default settings of all defined command-line flags.

func String

func String(envName string, paramName string, defaultValue string, desctiption string) *string

String defines a string parameter with specified parameter name, environment variable name, default value, and usage string. The return value is the address of a string variable that stores the value of the flag or the enviroment variable. ATTENSION: Be careful, empty string is valid.

func Uint

func Uint(envName string, paramName string, defaultValue uint, description string) *uint

Uint defines a uint parameter with specified parameter name, environment variable name, default value, and usage string. The return value is the address of a uint variable that stores the value of the flag or the enviroment variable.

func Uint64

func Uint64(envName string, paramName string, defaultValue uint64, description string) *uint64

Uint64 defines a uint64 parameter with specified parameter name, environment variable name, default value, and usage string. The return value is the address of a uint64 variable that stores the value of the flag or the enviroment variable.

Types

This section is empty.

Jump to

Keyboard shortcuts

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