MCPcopy Index your code
hub / github.com/expr-lang/expr / ExampleAsInt64

Function ExampleAsInt64

expr_test.go:319–339  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

317}
318
319func ExampleAsInt64() {
320 env := map[string]any{
321 "rating": 5.5,
322 }
323
324 program, err := expr.Compile("rating", expr.Env(env), expr.AsInt64())
325 if err != nil {
326 fmt.Printf("%v", err)
327 return
328 }
329
330 output, err := expr.Run(program, env)
331 if err != nil {
332 fmt.Printf("%v", err)
333 return
334 }
335
336 fmt.Printf("%v", output.(int64))
337
338 // Output: 5
339}
340
341func ExampleAsFloat64() {
342 program, err := expr.Compile("42", expr.AsFloat64())

Callers

nothing calls this directly

Calls 5

CompileFunction · 0.92
EnvStruct · 0.92
AsInt64Function · 0.92
RunFunction · 0.92
PrintfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…