@@ -23,7 +23,7 @@ type Configurator interface {
2323func GetEnvString (config Configurator , field string ) string {
2424 defer func () {
2525 if r := recover (); r != nil {
26- log .Panicf ("configurator has no field named '%s'" , field )
26+ log .Panicf ("configurator has no string field named '%s'" , field )
2727 }
2828 }()
2929 value , exists := os .LookupEnv (field )
@@ -38,6 +38,9 @@ func GetEnvString(config Configurator, field string) string {
3838func GetEnvBool (config Configurator , field string ) bool {
3939 defer func () {
4040 if r := recover (); r != nil {
41+ if reflect .ValueOf (config ).FieldByName (field ).IsValid () {
42+ log .Panicf ("configurator field '%s' is not a bool" , field )
43+ }
4144 log .Panicf ("configurator has no field named '%s'" , field )
4245 }
4346 }()
@@ -53,6 +56,9 @@ func GetEnvBool(config Configurator, field string) bool {
5356func GetEnvInt (config Configurator , field string ) int {
5457 defer func () {
5558 if r := recover (); r != nil {
59+ if reflect .ValueOf (config ).FieldByName (field ).IsValid () {
60+ log .Panicf ("configurator field '%s' is not an int" , field )
61+ }
5662 log .Panicf ("configurator has no field named '%s'" , field )
5763 }
5864 }()
@@ -68,6 +74,9 @@ func GetEnvInt(config Configurator, field string) int {
6874func GetEnvFloat (config Configurator , field string ) float64 {
6975 defer func () {
7076 if r := recover (); r != nil {
77+ if reflect .ValueOf (config ).FieldByName (field ).IsValid () {
78+ log .Panicf ("configurator field '%s' is not a float" , field )
79+ }
7180 log .Panicf ("configurator has no field named '%s'" , field )
7281 }
7382 }()
0 commit comments