mirror of
				https://github.com/SourceFellows/gobuch.git
				synced 2025-11-04 07:36:19 +01: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