Just seen the following code in net/http package, request.go: func (r *Request) WithContext(ctx context.Context) *Request { if ctx == nil { panic("nil context") } r2 := new(Request) *r2 = *r r2.ctx = ctx return r2 }
I'm wondering, if there's any benefit of writing* r2 := new(Request); *r2 = *r *rather than shorter *r2 := *r (example below) *or this is just matter of style preference? func (r *Request) WithContext(ctx context.Context) *Request { if ctx == nil { panic("nil context") } r2 := *r r2.ctx = ctx return &r2 } -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.