MCPcopy Create free account
hub / github.com/cel-expr/cel-go / formatDecimal

Function formatDecimal

ext/formatting.go:231–248  ·  view source on GitHub ↗
(arg ref.Val, locale string)

Source from the content-addressed store, hash-verified

229}
230
231func formatDecimal(arg ref.Val, locale string) (string, error) {
232 switch arg.Type() {
233 case types.IntType:
234 argInt, ok := arg.ConvertToType(types.IntType).Value().(int64)
235 if !ok {
236 return "", fmt.Errorf("could not convert \"%s\" to int64", arg.Value())
237 }
238 return fmt.Sprintf("%d", argInt), nil
239 case types.UintType:
240 argInt, ok := arg.ConvertToType(types.UintType).Value().(uint64)
241 if !ok {
242 return "", fmt.Errorf("could not convert \"%s\" to uint64", arg.Value())
243 }
244 return fmt.Sprintf("%d", argInt), nil
245 default:
246 return "", decimalFormatError(runtimeID, arg.Type().TypeName())
247 }
248}
249
250func matchLanguage(locale string) (language.Tag, error) {
251 matcher, err := makeMatcher(locale)

Callers 1

DecimalMethod · 0.85

Calls 5

decimalFormatErrorFunction · 0.85
TypeMethod · 0.65
ValueMethod · 0.65
ConvertToTypeMethod · 0.65
TypeNameMethod · 0.65

Tested by

no test coverage detected