gobuch/best-practices/context-value/main.go
2020-08-21 06:26:40 +02:00

16 lines
215 B
Go

package main
import (
"context"
"fmt"
)
type contextKey string
func main() {
var key contextKey = "test"
ctx := context.Background()
ctx = context.WithValue(ctx, key, "world")
fmt.Println(ctx.Value(key))
}