noctx
noctx copied to clipboard
noctx finds sending http request without context.Context.
```go // Sending an HTTP request and accepting context func SendWithContext(ctx context.Context, body io.Reader) error { // Change NewRequest to NewRequestWithContext and pass context it req, err := http.NewRequestWithContext(ctx, http.MethodPost,...
``` type key struct{} req, _ := http.NewRequest("POST", "", nil) req = req.WithContext(context.WithValue(req.Context(), key{}, 0)) ``` noctx raises this error: ``` should rewrite http.NewRequestWithContext or add (*Request).WithContext (noctx) req, _...
Thank you for the wonderful linter. This linter seems to be mainly net/http, but is it out of scope to issue a warning to methods that use database/sql without context.Context?
I'm always interested how to improve my code, but this one is a bit irritating to me. Maybe I'm wrong in doing so, but it seems like detection is too...
As described in [the docs](https://golang.org/pkg/net/http/#NewRequest), `http.NewRequest` uses the `context.Background` context which is supposed to be used in tests according to [the docs](https://golang.org/pkg/context/#Background). Therefore, it is cleaner to use `http.NewContext` in...
```go req, _ := http.NewRequest(http.MethodPost, url, nil) // want `should rewrite http.NewRequestWithContext or add \(\*Request\).WithContext` _, _ = func() (*http.Request, error) { return req, nil }() // OK cli.Do(req) ```...