Skip to content

Commit

Permalink
docs: godoc
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
  • Loading branch information
caarlos0 committed Aug 30, 2021
1 parent d96cac5 commit ac4c4be
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions env.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,14 @@ type OnSetFn func(tag string, value interface{}, isDefault bool)
type Options struct {
// Environment keys and values that will be accessible for the service.
Environment map[string]string

// TagName specifies another tagname to use rather than the default env.
TagName string

// RequiredIfNoDef automatically sets all env as required if they do not declare 'envDefault'
RequiredIfNoDef bool

// OnSet allows to run a function when a value is set
OnSet OnSetFn

// Sets to true if we have already configured once.
Expand Down Expand Up @@ -282,8 +285,7 @@ func get(field reflect.StructField, opts []Options) (val string, err error) {
}
}

onSetFn := getOnSetFn(opts)
if onSetFn != nil {
if onSetFn := getOnSetFn(opts); onSetFn != nil {
onSetFn(key, val, isDefault)
}
return val, err
Expand Down

0 comments on commit ac4c4be

Please sign in to comment.