File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -211,7 +211,7 @@ fmt.Println(cfg.Port) // 8080
211211### Usage message
212212
213213The ` Usage ` function prints a usage message documenting all defined environment variables.
214- An optional usage string can be added for each environment variable via the ` usage:"STRING" ` struct tag:
214+ An optional usage string can be added to environment variables using the ` usage:"STRING" ` struct tag:
215215
216216``` go
217217os.Unsetenv (" DB_HOST" )
Original file line number Diff line number Diff line change 77 "text/tabwriter"
88)
99
10- // cache maps the struct type to the [Var] slice parsed from it.
10+ // cache maps a struct type to the [Var] slice parsed from it.
1111// It is primarily needed to fix the following bug:
1212//
1313// var cfg struct {
@@ -19,7 +19,7 @@ import (
1919// It also speeds up [Usage], since there is no need to parse the struct again.
2020var cache = make (map [reflect.Type ][]Var )
2121
22- // Var holds the information about an environment variable parsed from the struct field.
22+ // Var holds the information about the environment variable parsed from a struct field.
2323type Var struct {
2424 Name string // The name of the variable.
2525 Type reflect.Type // The type of the variable.
@@ -33,7 +33,8 @@ type Var struct {
3333}
3434
3535// Usage writes a usage message documenting all defined environment variables to the given [io.Writer].
36- // An optional usage string can be added for each environment variable via the `usage:"STRING"` struct tag.
36+ // The caller must pass the same [Options] to both [Load] and [Usage], or nil.
37+ // An optional usage string can be added to environment variables using the `usage:"STRING"` struct tag.
3738// The format of the message can be customized by implementing the Usage([]env.Var, io.Writer, *env.Options) method on the cfg's type.
3839func Usage (cfg any , w io.Writer , opts * Options ) {
3940 pv := reflect .ValueOf (cfg )
You can’t perform that action at this time.
0 commit comments