Skip to content

Commit

Permalink
add missing getters type conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
grount authored and Daniel Gront committed Feb 23, 2021
1 parent 33a8f09 commit b97eac0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ func (ko *Koanf) Int64s(path string) []int64 {

var out []int64
switch v := o.(type) {
case []int64:
return v
case []int:
out = make([]int64, 0, len(v))
for _, vi := range v {
Expand Down Expand Up @@ -150,6 +152,12 @@ func (ko *Koanf) Ints(path string) []int {
switch v := o.(type) {
case []int:
return v
case []int64:
out = make([]int, 0, len(v))
for _, vi := range v {
out = append(out, int(vi))
}
return out
case []interface{}:
out = make([]int, 0, len(v))
for _, vi := range v {
Expand Down Expand Up @@ -233,6 +241,8 @@ func (ko *Koanf) Float64s(path string) []float64 {

var out []float64
switch v := o.(type) {
case []float64:
return v
case []interface{}:
out = make([]float64, 0, len(v))
for _, vi := range v {
Expand All @@ -243,7 +253,7 @@ func (ko *Koanf) Float64s(path string) []float64 {
if err != nil {
return []float64{}
}
out = append(out, float64(i))
out = append(out, i)
}
return out
}
Expand Down

0 comments on commit b97eac0

Please sign in to comment.