context.WithValue context.WithTimeout
func tctx() {
    f := func() context.Context {
        ctx := context.TODO()
        ctx = context.WithValue(ctx, "k", "v")
        myprint(ctx.Value("k"))
        return ctx
    }
    ctx := f()
    ctx, _ = context.WithTimeout(ctx, 32*time.Second)
    myprint("2", ctx.Value("k"))
}
func myprint(l ...interface{}) {
    fmt.Println(l...)
}
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号