Documentation ¶
Index ¶
Constants ¶
const ( // DefaultListFormat constant to use to display usage in a list format DefaultListFormat = `` /* 245-byte string literal not displayed */ // DefaultTableFormat constant to use to display usage in a tabular format DefaultTableFormat = `` /* 222-byte string literal not displayed */ )
Variables ¶
var ErrEmptyPrefix = errors.New("prefix must be non-empty")
ErrEmptyPrefix indicates that prefix is empty.
var ErrInvalidSpecification = errors.New("specification must be a struct pointer")
ErrInvalidSpecification indicates that a specification is of the wrong type.
Functions ¶
func FindUnknownEnvVariablesByPrefix ¶
FindUnknownEnvVariablesByPrefix checks that no environment variables with the prefix are set that we don't know how or want to parse. This is likely only meaningful with a non-empty prefix. Returns list of unknown env variables.
func PrintUsage ¶
func PrintUsage(spec interface{}) error
PrintUsage writes usage information to stdout using the default header and table format
Types ¶
type Decoder ¶
Decoder has the same semantics as Setter, but takes higher precedence. It is provided for historical compatibility.
type FieldUnmarshalResult ¶
type FieldUnmarshalResult struct { KeyName string FieldName string TypeName string Value string Err error }
A FieldUnmarshalResult. Err is filled when an environment variable is required but missing or cannot be converted to the type required by a struct field during assignment.
type FieldUnmarshalResults ¶
type FieldUnmarshalResults []FieldUnmarshalResult
func Unmarshal ¶
func Unmarshal(spec interface{}) (FieldUnmarshalResults, error)
Unmarshal populates the specified struct based on environment variables and returns a slice with result of parsing each struct's field.
func (FieldUnmarshalResults) PrettyPrint ¶
func (f FieldUnmarshalResults) PrettyPrint()
PrettyPrint prints verbose information about env variables specification, current values and whether it was parsed correctly.