2626type context struct {
2727 name string
2828 prefix string
29- prefixTag bool
29+ prefixCustomNames bool
3030 customName string
3131 defaultVal string
3232 usingDefault bool
@@ -46,8 +46,8 @@ type Options struct {
4646 // Prefix allows specifying a prefix for each key.
4747 Prefix string
4848
49- // PrefixTag enables prefixes for the custom names set via struct tags
50- PrefixTag bool
49+ // PrefixCustomNames enables prefixes for the custom names set via struct tags
50+ PrefixCustomNames bool
5151
5252 // AllOptional determines whether to not throw errors by default for any key
5353 // that is not found. AllOptional=true means errors will not be thrown.
@@ -101,12 +101,12 @@ func InitWithOptions(conf interface{}, opts Options) error {
101101 elem := value .Elem ()
102102
103103 ctx := context {
104- name : opts .Prefix ,
105- prefix : opts .Prefix ,
106- prefixTag : opts .PrefixTag ,
107- optional : opts .AllOptional ,
108- leaveNil : opts .LeaveNil ,
109- allowUnexported : opts .AllowUnexported ,
104+ name : opts .Prefix ,
105+ prefix : opts .Prefix ,
106+ prefixCustomNames : opts .PrefixCustomNames ,
107+ optional : opts .AllOptional ,
108+ leaveNil : opts .LeaveNil ,
109+ allowUnexported : opts .AllowUnexported ,
110110 }
111111 switch elem .Kind () {
112112 case reflect .Ptr :
@@ -182,28 +182,28 @@ func readStruct(value reflect.Value, ctx *context) (nonNil bool, err error) {
182182 case field .Kind () == reflect .Struct && ! isUnmarshaler (fieldType ):
183183 var nonNilIn bool
184184 nonNilIn , err = readStruct (field , & context {
185- name : combineName (ctx .name , name ),
186- prefix : ctx .prefix ,
187- prefixTag : ctx .prefixTag ,
188- optional : ctx .optional || tag .optional ,
189- defaultVal : tag .defaultVal ,
190- parents : parents ,
191- leaveNil : ctx .leaveNil ,
192- allowUnexported : ctx .allowUnexported ,
185+ name : combineName (ctx .name , name ),
186+ prefix : ctx .prefix ,
187+ prefixCustomNames : ctx .prefixCustomNames ,
188+ optional : ctx .optional || tag .optional ,
189+ defaultVal : tag .defaultVal ,
190+ parents : parents ,
191+ leaveNil : ctx .leaveNil ,
192+ allowUnexported : ctx .allowUnexported ,
193193 })
194194 nonNil = nonNil || nonNilIn
195195 default :
196196 var ok bool
197197 ok , err = setField (field , & context {
198- name : combineName (ctx .name , name ),
199- prefix : ctx .prefix ,
200- prefixTag : ctx .prefixTag ,
201- customName : tag .customName ,
202- optional : ctx .optional || tag .optional ,
203- defaultVal : tag .defaultVal ,
204- parents : parents ,
205- leaveNil : ctx .leaveNil ,
206- allowUnexported : ctx .allowUnexported ,
198+ name : combineName (ctx .name , name ),
199+ prefix : ctx .prefix ,
200+ prefixCustomNames : ctx .prefixCustomNames ,
201+ customName : tag .customName ,
202+ optional : ctx .optional || tag .optional ,
203+ defaultVal : tag .defaultVal ,
204+ parents : parents ,
205+ leaveNil : ctx .leaveNil ,
206+ allowUnexported : ctx .allowUnexported ,
207207 })
208208 nonNil = nonNil || ok
209209 }
@@ -471,7 +471,7 @@ func readValue(ctx *context) (string, error) {
471471
472472func makeAllPossibleKeys (ctx * context ) (res []string ) {
473473 if ctx .customName != "" {
474- if ctx .prefixTag {
474+ if ctx .prefixCustomNames {
475475 return []string {ctx .prefix + "_" + ctx .customName }
476476 }
477477 return []string {ctx .customName }
0 commit comments