Skip to content

Commit 3e60436

Browse files
committed
update docs
1 parent 1d91c9b commit 3e60436

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ fmt.Println(cfg.Port) // 8080
211211
### Usage message
212212

213213
The `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
217217
os.Unsetenv("DB_HOST")

usage.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
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.
2020
var 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.
2323
type 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.
3839
func Usage(cfg any, w io.Writer, opts *Options) {
3940
pv := reflect.ValueOf(cfg)

0 commit comments

Comments
 (0)