Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/caarlos0/env
/ functions
Functions
212 in github.com/caarlos0/env
⨍
Functions
212
◇
Types & classes
57
↓ 90 callers
Function
Parse
Parse parses a struct containing `env` tags and loads its values from environment variables.
env.go:286
↓ 67 callers
Function
isNoErr
(tb testing.TB, err error)
env_test.go:1926
↓ 62 callers
Function
isEqual
(tb testing.TB, a, b interface{})
env_test.go:1934
↓ 53 callers
Function
isTrue
(tb testing.TB, b bool)
env_test.go:1898
↓ 51 callers
Method
Is
Is conforms with errors.Is.
error.go:50
↓ 45 callers
Function
isErrorWithMessage
(tb testing.TB, err error, msg string)
env_test.go:1914
↓ 41 callers
Function
ParseWithOptions
ParseWithOptions parses a struct containing `env` tags and loads its values from environment variables.
env.go:292
↓ 5 callers
Function
newParseError
(sf reflect.StructField, err error)
error.go:66
↓ 4 callers
Function
parseInternal
(v interface{}, processField processFieldFn, opts Options)
env.go:347
↓ 3 callers
Function
areEqual
copied from https://github.com/matryer/is
env_test.go:1945
↓ 3 callers
Function
defaultOptions
()
env.go:199
↓ 3 callers
Function
doParse
(ref reflect.Value, processField processFieldFn, opts Options)
env.go:360
↓ 3 callers
Function
newNoParserError
(sf reflect.StructField)
error.go:87
↓ 3 callers
Function
newParseValueError
(message string, err error)
error.go:167
↓ 2 callers
Method
Error
()
error.go:70
↓ 2 callers
Function
GetFieldParams
GetFieldParams parses a struct containing `env` tags and returns information about tags it found.
env.go:322
↓ 2 callers
Function
GetFieldParamsWithOptions
GetFieldParamsWithOptions parses a struct containing `env` tags and returns information about tags it found.
env.go:328
↓ 2 callers
Function
ToMap
ToMap Converts list of env vars as provided by os.Environ() to map you can use as Options.Environment field
env.go:865
↓ 2 callers
Method
UnmarshalText
(text []byte)
env_test.go:1574
↓ 2 callers
Function
customOptions
(opts Options)
env.go:246
↓ 2 callers
Function
isFalse
(tb testing.TB, b bool)
env_test.go:1906
↓ 2 callers
Function
newAggregateError
(initErr error)
error.go:24
↓ 2 callers
Function
toEnvName
(input string)
env.go:528
↓ 2 callers
Function
toMap
(env []string)
env_tomap.go:7
↓ 1 callers
Function
Must
Must panic is if err is not nil, and returns t otherwise.
env.go:313
↓ 1 callers
Function
asTextUnmarshaler
(field reflect.Value)
env.go:821
↓ 1 callers
Function
defaultTypeParsers
()
env.go:85
↓ 1 callers
Function
doParseField
( refField reflect.Value, refTypeField reflect.StructField, processField processFieldFn, opts Options, )
env.go:385
↓ 1 callers
Function
doParseSlice
(ref reflect.Value, processField processFieldFn, opts Options)
env.go:449
↓ 1 callers
Method
expand
expand replaces ${var} or $var in val, expanding the values it refers to as well. visiting holds the variables being expanded, so a reference back to
env.go:183
↓ 1 callers
Function
get
(fieldParams FieldParams, opts Options)
env.go:605
↓ 1 callers
Function
getFromFile
(filename string)
env.go:661
↓ 1 callers
Function
getOr
(key, defaultValue string, defExists bool, envs map[string]string)
env.go:666
↓ 1 callers
Function
handleMap
(field reflect.Value, value string, sf reflect.StructField, funcMap map[reflect.Type]ParserFunc)
env.go:768
↓ 1 callers
Function
handleSlice
(field reflect.Value, value string, sf reflect.StructField, funcMap map[reflect.Type]ParserFunc)
env.go:727
↓ 1 callers
Function
isInvalidPtr
(v reflect.Value)
env.go:869
↓ 1 callers
Function
isNil
copied from https://github.com/matryer/is
env_test.go:1961
↓ 1 callers
Function
isSliceOfStructs
(refTypeField reflect.StructField)
env.go:430
↓ 1 callers
Function
isZero
(v reflect.Value)
env.go:236
↓ 1 callers
Function
mergeOptions
(target, source *T)
env.go:210
↓ 1 callers
Function
newEmptyVarError
(key string)
error.go:138
↓ 1 callers
Function
newLoadFileContentError
(filename, key string, err error)
error.go:153
↓ 1 callers
Function
newNoSupportedTagOptionError
(tag string)
error.go:102
↓ 1 callers
Function
newVarIsNotSetError
(key string)
error.go:120
↓ 1 callers
Function
optionsWithEnvPrefix
(field reflect.StructField, opts Options)
env.go:268
↓ 1 callers
Function
optionsWithSliceEnvPrefix
(opts Options, index int)
env.go:252
↓ 1 callers
Function
parseFieldParams
(field reflect.StructField, opts Options)
env.go:562
↓ 1 callers
Function
parseKeyForOption
split the env tag's key into the expected key and desired option, if any.
env.go:656
↓ 1 callers
Function
parseTextUnmarshalers
(field reflect.Value, data []string, sf reflect.StructField)
env.go:837
↓ 1 callers
Function
set
(field reflect.Value, sf reflect.StructField, value string, funcMap map[reflect.Type]ParserFunc)
env.go:680
Method
Error
()
error.go:32
Method
Error
()
error.go:77
Method
Error
()
error.go:91
Method
Error
()
error.go:106
Method
Error
()
error.go:124
Method
Error
()
error.go:142
Method
Error
()
error.go:157
Method
Error
()
error.go:171
Function
Example
Basic package usage example.
example_test.go:11
Function
ExampleParse
Parse the environment into a struct.
example_test.go:30
Function
ExampleParseAs
Parse the environment into a struct using generics.
example_test.go:44
Function
ExampleParseWithOptions_allFieldsRequired
Make all fields required by default.
example_test.go:260
Function
ExampleParseWithOptions_customTypes
Parse using extra options.
example_test.go:233
Function
ExampleParseWithOptions_onSet
You might want to listen to value sets and, for example, log something or do some other kind of logic.
example_test.go:179
Function
ExampleParseWithOptions_prefix
Setting prefixes for the entire config.
example_test.go:341
Function
ExampleParseWithOptions_setEnv
Set a custom environment. By default, `os.Environ()` is used.
example_test.go:279
Function
ExampleParseWithOptions_tagName
Use a different tag name than `env` and `envDefault`.
example_test.go:357
Function
ExampleParseWithOptions_useFieldName
If you don't want to set the `env` tag on every field, you can use the `UseFieldNameByDefault` option. It will use the field name to define the envir
example_test.go:379
Function
ExampleParse_complexSlices
Handling slices of complex types.
example_test.go:299
Function
ExampleParse_customTimeFormat
By default, env supports anything that implements the `TextUnmarshaler` interface, which includes `time.Time`. The upside is that depending on the fo
example_test.go:211
Function
ExampleParse_errorHandling
TODO: envSeperator
example_test.go:420
Function
ExampleParse_expand
If you set the `expand` option, environment variables (either in `${var}` or `$var` format) in the string will be replaced according with the actual v
example_test.go:123
Function
ExampleParse_fromFile
The `env` tag option `file` (e.g., `env:"tagKey,file"`) can be added in order to indicate that the value of the variable shall be loaded from a file.
example_test.go:400
Function
ExampleParse_init
You can automatically initialize `nil` pointers regardless of if a variable is set for them or not. This behavior can be enabled by using the `init` t
example_test.go:141
Function
ExampleParse_notEmpty
While `required` demands the environment variable to be set, it doesn't check its value. If you want to make sure the environment is set and not empty
example_test.go:73
Function
ExampleParse_prefix
Setting prefixes for inner types.
example_test.go:322
Function
ExampleParse_required
()
example_test.go:57
Function
ExampleParse_separator
You can use `envSeparator` to define which character should be used to separate array items in a string. Similarly, you can use `envKeyValSeparator` t
example_test.go:107
Function
ExampleParse_setDefaults
You can define the default value for a field by either using the `envDefault` tag, or when initializing the `struct`. Default values defined as `stru
example_test.go:162
Function
ExampleParse_unset
The `env` tag option `unset` (e.g., `env:"tagKey,unset"`) can be added to ensure that some environment variable is unset after reading it.
example_test.go:89
Function
Example_parseEmptyEnvFallsBackToDefault
An environment variable that is set but empty falls back to envDefault.
example_test.go:485
Function
Example_setDefaultsForZeroValuesOnly
You can avoid setting defaults for non zero values This could be useful for loading data from config file first and then filling the rest from env
example_test.go:462
Function
ParseAs
ParseAs parses the given struct type containing `env` tags and loads its values from environment variables.
env.go:298
Function
ParseAsWithOptions
ParseAsWithOptions parses the given struct type containing `env` tags and loads its values from environment variables.
env.go:306
Function
TestBadSeparator
(t *testing.T)
env_test.go:865
Function
TestBase64Password
(t *testing.T)
env_test.go:2009
Function
TestComplePrefix
(t *testing.T)
env_test.go:1718
Function
TestCustomParser
(t *testing.T)
env_test.go:1109
Function
TestCustomParserBasicType
(t *testing.T)
env_test.go:1236
Function
TestCustomParserBasicUnsupported
(t *testing.T)
env_test.go:1347
Function
TestCustomParserError
(t *testing.T)
env_test.go:1194
Function
TestCustomParserNotCalledForNonAlias
(t *testing.T)
env_test.go:1319
Function
TestCustomParserUint64Alias
(t *testing.T)
env_test.go:1264
Function
TestCustomSliceType
(t *testing.T)
env_test.go:1555
Function
TestCustomTimeParser
(t *testing.T)
env_test.go:1580
Function
TestEmptyOption
(t *testing.T)
env_test.go:1376
Function
TestEmptyVars
(t *testing.T)
env_test.go:682
Function
TestEnvBleed
(t *testing.T)
env_test.go:2426
Function
TestErrorIs
(t *testing.T)
env_test.go:1786
Function
TestErrorNotEmptySet
(t *testing.T)
env_test.go:956
next →
1–100 of 212, ranked by callers