Skip to content

Commit

Permalink
Merge pull request #148 from batazor/fix
Browse files Browse the repository at this point in the history
Fix index helpers
  • Loading branch information
moul authored Dec 4, 2019
2 parents 3a6b47d + b244c9c commit 066f210
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ var ProtoHelpersFuncMap = template.FuncMap{
"trimstr": func(cutset, s string) string {
return strings.Trim(s, cutset)
},
"index": func(array interface{}, i int32) interface{} {
"index": func(array interface{}, i int) interface{} {
slice := reflect.ValueOf(array)
if slice.Kind() != reflect.Slice {
panic("Error in index(): given a non-slice type")
}
if i < 0 || int(i) >= slice.Len() {
if i < 0 || i >= slice.Len() {
panic("Error in index(): index out of bounds")
}
return slice.Index(int(i)).Interface()
return slice.Index(i).Interface()
},
"add": func(a int, b int) int {
return a + b
Expand Down

0 comments on commit 066f210

Please sign in to comment.