// Code generated by baton-sdk. DO NOT EDIT!!!
package config
import "reflect"
type App struct {
AppClientId string `mapstructure:"app-client-id"`
AppClientSecret string `mapstructure:"app-client-secret"`
BaseUrl string `mapstructure:"base-url"`
}
func (c *App) findFieldByTag(tagValue string) (any, bool) {
v := reflect.ValueOf(c).Elem() // Dereference pointer to struct
t := v.Type()
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
tag := field.Tag.Get("mapstructure")
if tag == tagValue {
return v.Field(i).Interface(), true
}
}
return nil, false
}
func (c *App) GetStringSlice(fieldName string) []string {
v, ok := c.findFieldByTag(fieldName)
if !ok {
return []string{}
}
t, ok := v.([]string)
if !ok {
panic("wrong type")
}
return t
}
func (c *App) GetString(fieldName string) string {
v, ok := c.findFieldByTag(fieldName)
if !ok {
return ""
}
if t, ok := v.(string); ok {
return t
}
if t, ok := v.([]byte); ok {
return string(t)
}
panic("wrong type")
}
func (c *App) GetInt(fieldName string) int {
v, ok := c.findFieldByTag(fieldName)
if !ok {
return 0
}
t, ok := v.(int)
if !ok {
panic("wrong type")
}
return t
}
func (c *App) GetBool(fieldName string) bool {
v, ok := c.findFieldByTag(fieldName)
if !ok {
return false
}
t, ok := v.(bool)
if !ok {
panic("wrong type")
}
return t
}
func (c *App) GetStringMap(fieldName string) map[string]any {
v, ok := c.findFieldByTag(fieldName)
if !ok {
return map[string]any{}
}
t, ok := v.(map[string]any)
if !ok {
panic("wrong type")
}
return t
}