Skip to content

Commit

Permalink
fix: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Sep 15, 2024
1 parent 5b0c645 commit 676dd6a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ linters:
$ golangci-lint run

# Only noctx execute
golangci-lint run --disable-all -E noctx
golangci-lint run --enable-only noctx
```

## Detection rules

- Executing following functions
- `net/http.Get`
- `net/http.Head`
Expand All @@ -68,6 +69,7 @@ golangci-lint run --disable-all -E noctx
- `http.Request` returned by `http.NewRequest` function and passes it to other function.

## How to fix

- Send http request using `(*http.Client).Do(*http.Request)` method.
- In Go 1.13 and later, use `http.NewRequestWithContext` function instead of using `http.NewRequest` function.
- In Go 1.12 and earlier, call `(http.Request).WithContext(ctx)` after `http.NewRequest`.
Expand Down Expand Up @@ -168,6 +170,7 @@ func main() {
```

## Reference

- [net/http - NewRequest](https://golang.org/pkg/net/http/#NewRequest)
- [net/http - NewRequestWithContext](https://golang.org/pkg/net/http/#NewRequestWithContext)
- [net/http - Request.WithContext](https://golang.org/pkg/net/http/#Request.WithContext)
Expand Down

0 comments on commit 676dd6a

Please sign in to comment.