flagutil

package
v0.0.0-...-0ccc1a6 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetFlagsFromEnv

func SetFlagsFromEnv(fs *flag.FlagSet, prefix string) (err error)

SetFlagsFromEnv parses all registered flags in the given flagset, and if they are not already set it attempts to set their values from environment variables. Environment variables take the name of the flag but are UPPERCASE, and any dashes are replaced by underscores. Environment variables additionally are prefixed by the given string followed by and underscore. For example, if prefix=PREFIX: some-flag => PREFIX_SOME_FLAG

func SetFlagsFromEnvFile

func SetFlagsFromEnvFile(fs *flag.FlagSet, prefix string, path string) (err error)

SetFlagsFromEnvFile iterates the given flagset and if any flags are not already set it attempts to set their values from the given env file. Env files may have KEY=VALUE lines where the environment variable names are in UPPERCASE, prefixed by the given PREFIX, and dashes are replaced by underscores. For example, if prefix=PREFIX, some-flag is named PREFIX_SOME_FLAG. Comment lines are skipped, but more complex env file parsing is not performed.

Types

type IPv4Flag

type IPv4Flag struct {
	// contains filtered or unexported fields
}

IPv4Flag parses a string into a net.IP after asserting that it is an IPv4 address. This type implements the flag.Value interface.

func (*IPv4Flag) IP

func (f *IPv4Flag) IP() net.IP

func (*IPv4Flag) Set

func (f *IPv4Flag) Set(v string) error

func (*IPv4Flag) String

func (f *IPv4Flag) String() string

type StringSliceFlag

type StringSliceFlag []string

StringSliceFlag parses a comma-delimited list of strings into a []string. This type implements the flag.Value interface.

func (*StringSliceFlag) Set

func (ss *StringSliceFlag) Set(v string) error

func (*StringSliceFlag) String

func (ss *StringSliceFlag) String() string

Jump to

Keyboard shortcuts

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