type Request struct {
...
}
r1 := new(Request)
r2 := &Request{}r1 和 r2 有什么區(qū)別嗎?我是看到標(biāo)準(zhǔn)庫中 net/http/request.go func (r *Request) WithContext(ctx context.Context) *Request的實(shí)現(xiàn)用到了new, 看了很多網(wǎng)上的資料都找不到為什么要用new.
- 1 回答
- 0 關(guān)注
- 562 瀏覽
添加回答
舉報
0/150
提交
取消