github.com/HaHadaxigua/yaegi@v1.0.1/_test/context.go (about)

     1  package main
     2  
     3  import "context"
     4  
     5  func get(ctx context.Context, k string) string {
     6  	var r string
     7  	if v := ctx.Value(k); v != nil {
     8  		r = v.(string)
     9  	}
    10  	return r
    11  }
    12  
    13  func main() {
    14  	ctx := context.WithValue(context.Background(), "hello", "world")
    15  	println(get(ctx, "hello"))
    16  }
    17  
    18  // Output:
    19  // world