Skip to content

Commit 0b4d8a6

Browse files
authored
fix: skip fields without env key in onSet (#266)
Options.OnSet gets called on _all_ fields, even the ones that _don't_ have an `env` key defined. This simply ignore those. Signed-off-by: Ayman Bagabas <[email protected]>
1 parent 3f7d8cf commit 0b4d8a6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

env.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,9 @@ func get(field reflect.StructField, opts Options) (val string, err error) {
307307
}
308308

309309
if opts.OnSet != nil {
310-
opts.OnSet(key, val, isDefault)
310+
if ownKey != "" {
311+
opts.OnSet(key, val, isDefault)
312+
}
311313
}
312314
return val, err
313315
}

0 commit comments

Comments
 (0)