fix type int32 in index helper
This commit is contained in:
		| @@ -91,15 +91,15 @@ var ProtoHelpersFuncMap = template.FuncMap{ | |||||||
| 	"trimstr": func(cutset, s string) string { | 	"trimstr": func(cutset, s string) string { | ||||||
| 		return strings.Trim(s, cutset) | 		return strings.Trim(s, cutset) | ||||||
| 	}, | 	}, | ||||||
| 	"index": func(array interface{}, i int) interface{} { | 	"index": func(array interface{}, i int32) interface{} { | ||||||
| 		slice := reflect.ValueOf(array) | 		slice := reflect.ValueOf(array) | ||||||
| 		if slice.Kind() != reflect.Slice { | 		if slice.Kind() != reflect.Slice { | ||||||
| 			panic("Error in index(): given a non-slice type") | 			panic("Error in index(): given a non-slice type") | ||||||
| 		} | 		} | ||||||
| 		if i < 0 || i >= slice.Len() { | 		if i < 0 || int(i) >= slice.Len() { | ||||||
| 			panic("Error in index(): index out of bounds") | 			panic("Error in index(): index out of bounds") | ||||||
| 		} | 		} | ||||||
| 		return slice.Index(i).Interface() | 		return slice.Index(int(i)).Interface() | ||||||
| 	}, | 	}, | ||||||
| 	"snakeCase":               xstrings.ToSnakeCase, | 	"snakeCase":               xstrings.ToSnakeCase, | ||||||
| 	"getProtoFile":            getProtoFile, | 	"getProtoFile":            getProtoFile, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user