mirror of
https://github.com/spf13/viper
synced 2024-12-24 12:37:02 +00:00
Adds Getter and related code for IntSlices
This commit is contained in:
parent
b5e8006cbe
commit
1d33b640d9
1 changed files with 8 additions and 0 deletions
8
viper.go
8
viper.go
|
@ -641,6 +641,8 @@ func (v *Viper) Get(key string) interface{} {
|
||||||
return cast.ToDuration(val)
|
return cast.ToDuration(val)
|
||||||
case []string:
|
case []string:
|
||||||
return cast.ToStringSlice(val)
|
return cast.ToStringSlice(val)
|
||||||
|
case []int:
|
||||||
|
return cast.ToIntSlice(val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,6 +684,12 @@ func (v *Viper) GetInt(key string) int {
|
||||||
return cast.ToInt(v.Get(key))
|
return cast.ToInt(v.Get(key))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetIntSlice returns the value associated with the key as an integer slice.
|
||||||
|
func GetIntSlice(key string) []int { return v.GetIntSlice(key) }
|
||||||
|
func (v *Viper) GetIntSlice(key string) []int {
|
||||||
|
return cast.ToIntSlice(v.Get(key))
|
||||||
|
}
|
||||||
|
|
||||||
// GetInt64 returns the value associated with the key as an integer.
|
// GetInt64 returns the value associated with the key as an integer.
|
||||||
func GetInt64(key string) int64 { return v.GetInt64(key) }
|
func GetInt64(key string) int64 { return v.GetInt64(key) }
|
||||||
func (v *Viper) GetInt64(key string) int64 {
|
func (v *Viper) GetInt64(key string) int64 {
|
||||||
|
|
Loading…
Reference in a new issue