fatcontext/contrib/example.go

22 lines
318 B
Go
Raw Normal View History

2024-03-27 19:24:38 +01:00
package contrib
import "context"
func ok() {
ctx := context.Background()
for i := 0; i < 10; i++ {
ctx := context.WithValue(ctx, "key", i)
_ = ctx
}
}
func notOk() {
ctx := context.Background()
for i := 0; i < 10; i++ {
ctx = context.WithValue(ctx, "key", i) // "nested context in loop"
2024-03-27 19:24:38 +01:00
_ = ctx
}
}