github.com/traefik/yaegi@v0.15.1/_test/context2.go (about) 1 package main 2 3 import "context" 4 5 func get(ctx context.Context, k string) string { 6 var r string 7 var ok bool 8 if v := ctx.Value(k); v != nil { 9 r, ok = v.(string) 10 println(ok) 11 } 12 return r 13 } 14 15 func main() { 16 ctx := context.WithValue(context.Background(), "hello", "world") 17 println(get(ctx, "hello")) 18 } 19 20 // Output: 21 // true 22 // world