MCPcopy Create free account
hub / github.com/caarlos0/env / ExampleParse_unset

Function ExampleParse_unset

example_test.go:89–100  ·  view source on GitHub ↗

The `env` tag option `unset` (e.g., `env:"tagKey,unset"`) can be added to ensure that some environment variable is unset after reading it.

()

Source from the content-addressed store, hash-verified

87// The `env` tag option `unset` (e.g., `env:"tagKey,unset"`) can be added
88// to ensure that some environment variable is unset after reading it.
89func ExampleParse_unset() {
90 type Config struct {
91 Secret string `env:"SECRET,unset"`
92 }
93 os.Setenv("SECRET", "1234")
94 var cfg Config
95 if err := Parse(&cfg); err != nil {
96 fmt.Println(err)
97 }
98 fmt.Printf("%+v - %s", cfg, os.Getenv("SECRET"))
99 // Output: {Secret:1234} -
100}
101
102// You can use `envSeparator` to define which character should be used to
103// separate array items in a string.

Callers

nothing calls this directly

Calls 1

ParseFunction · 0.85

Tested by

no test coverage detected