3 ms·
And if the functions in question were properly named func NewWithValue(parent Context, key, val interface{}) Context func NewBackground() Context you w
by eternalban 6y ago
And if the functions in question were properly named
func NewWithValue(parent Context, key, val interface{}) Context
func NewBackground() Context
you wouldn't even have to guess.
- masklinn 6y agoIDK, having never seen or used Go's contexts, the `With` prefix immediately made me think that it likely created a new context: it's a common naming convention in Rust or Python. I'd have expected `SetValue` for updating keys in-place. That `WithValue` creates an "inheritance" relationship surprised me a lot more, that I did not expect.
- morelisp 6y ago`context.Background()` doesn't allocate anything, it gives you the runtime's singular top-level context.