mirror of
https://github.com/SourceFellows/gobuch.git
synced 2025-07-21 07:30:44 +02:00
initial import
This commit is contained in:
15
best-practices/context-value/main.go
Normal file
15
best-practices/context-value/main.go
Normal file
@ -0,0 +1,15 @@
|
||||
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))
|
||||
}
|
Reference in New Issue
Block a user