Add envprefix tag

This commit is contained in:
Dan
2021-10-22 11:28:58 +07:00
committed by Alec Thomas
parent 749d3f0752
commit 2770a34ce6
5 changed files with 53 additions and 0 deletions
+2
View File
@@ -32,6 +32,7 @@ type Tag struct {
Xor []string
Vars Vars
Prefix string // Optional prefix on anonymous structs. All sub-flags will have this prefix.
EnvPrefix string
Embed bool
Aliases []string
Negatable bool
@@ -196,6 +197,7 @@ func hydrateTag(t *Tag, typeName string, isBool bool) error {
t.Xor = append(t.Xor, strings.FieldsFunc(xor, tagSplitFn)...)
}
t.Prefix = t.Get("prefix")
t.EnvPrefix = t.Get("envprefix")
t.Embed = t.Has("embed")
negatable := t.Has("negatable")
if negatable && !isBool {