Created
July 9, 2020 20:28
-
-
Save RicardoLinck/34f5b7a33fc057f8b8b28644a98ba41d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
) | |
func main() { | |
ctx := context.Background() | |
ctx = addValue(ctx) | |
readValue(ctx) | |
} | |
func addValue(ctx context.Context) context.Context { | |
return context.WithValue(ctx, "key", "test-value") | |
} | |
func readValue(ctx context.Context) { | |
val := ctx.Value("key") | |
fmt.Println(val) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment