MCPcopy
hub / github.com/google/go-jsonnet / getInt

Method getInt

interpreter.go:1077–1089  ·  view source on GitHub ↗
(val value)

Source from the content-addressed store, hash-verified

1075}
1076
1077func (i *interpreter) getInt(val value) (int, error) {
1078 num, err := i.getNumber(val)
1079 if err != nil {
1080 return 0, err
1081 }
1082 // We conservatively convert ot int32, so that it can be machine-sized int
1083 // on any machine. And it's used only for indexing anyway.
1084 intNum := int(int32(num.value))
1085 if float64(intNum) != num.value {
1086 return 0, i.Error(fmt.Sprintf("Expected an integer, but got %v", num.value))
1087 }
1088 return intNum, nil
1089}
1090
1091func (i *interpreter) evaluateInt(pv potentialValue) (int, error) {
1092 v, err := i.evaluatePV(pv)

Callers 8

evaluateIntMethod · 0.95
builtinMakeArrayFunction · 0.80
builtinRangeFunction · 0.80
builtinBase64Function · 0.80
builtinSubstrFunction · 0.80
builtinSplitLimitFunction · 0.80
builtinSplitLimitRFunction · 0.80
builtinRemoveAtFunction · 0.80

Calls 2

getNumberMethod · 0.95
ErrorMethod · 0.95

Tested by

no test coverage detected