Skip to content

Commit 5d7eb0c

Browse files
committedAug 7, 2024··
docs: fix bad example
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
1 parent fb84246 commit 5d7eb0c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed
 

‎example_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ func ExampleParseWithOptions_customTypes() {
241241
// Make all fields required by default.
242242
func ExampleParseWithOptions_allFieldsRequired() {
243243
type Config struct {
244-
Username string `env:"USERNAME" envDefault:"admin"`
245-
Password string `env:"PASSWORD"`
244+
Username string `env:"EX_USERNAME" envDefault:"admin"`
245+
Password string `env:"EX_PASSWORD"`
246246
}
247247

248248
var cfg Config
@@ -252,23 +252,23 @@ func ExampleParseWithOptions_allFieldsRequired() {
252252
fmt.Println(err)
253253
}
254254
fmt.Printf("%+v\n", cfg)
255-
// Output: env: required environment variable "PASSWORD" is not set
255+
// Output: env: required environment variable "EX_PASSWORD" is not set
256256
// {Username:admin Password:}
257257
}
258258

259259
// Set a custom environment.
260260
// By default, `os.Environ()` is used.
261261
func ExampleParseWithOptions_setEnv() {
262262
type Config struct {
263-
Username string `env:"USERNAME" envDefault:"admin"`
264-
Password string `env:"PASSWORD"`
263+
Username string `env:"EX_USERNAME" envDefault:"admin"`
264+
Password string `env:"EX_PASSWORD"`
265265
}
266266

267267
var cfg Config
268268
if err := ParseWithOptions(&cfg, Options{
269269
Environment: map[string]string{
270-
"USERNAME": "john",
271-
"PASSWORD": "cena",
270+
"EX_USERNAME": "john",
271+
"EX_PASSWORD": "cena",
272272
},
273273
}); err != nil {
274274
fmt.Println(err)

0 commit comments

Comments
 (0)
Please sign in to comment.