Skip to content

Commit

Permalink
add new tag to set env as optional
Browse files Browse the repository at this point in the history
  • Loading branch information
isogram authored and agungdwiprasetyo committed May 14, 2024
1 parent 911592c commit 31b767c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion candihelper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ func MustParseEnv(target interface{}) {

val, ok := os.LookupEnv(key)
if !ok {
mErrs.Append(key, fmt.Errorf("missing %s environment", key))
if typ.Tag.Get("optional") != "true" {
mErrs.Append(key, fmt.Errorf("missing %s environment", key))
}
continue
}

Expand Down

0 comments on commit 31b767c

Please sign in to comment.