Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kkHAIKE committed Sep 19, 2022
1 parent 6ca9469 commit bb07f32
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func call8() {
```

## Tips

You can break ctx inheritance by this way, eg: [issue](https://github.com/kkHAIKE/contextcheck/issues/2).
### need break ctx inheritance
eg: [issue](https://github.com/kkHAIKE/contextcheck/issues/2).

```go
func call1(ctx context.Context) {
Expand All @@ -94,6 +94,7 @@ func NoInheritCancel(_ context.Context) (context.Context,context.CancelFunc) {
}
```

### skip check specify function
You can add `// nolint: contextcheck` in function decl doc comment, to skip this linter in some false-positive case.

```go
Expand All @@ -111,6 +112,25 @@ func call3() {
}
```

### force mark specify function have server-side http.Request parameter
default behavior is mark http.HandlerFunc only.

```go
// @contextcheck(req_has_ctx)
func writeErr(w http.ResponseWriter, r *http.Request, err error) {
doSomeThing(r.Context())
}

func handler(w http.ResponseWriter, r *http.Request) {
...
if err != nil {
writeErr(w, r, err)
return
}
...
}
```

## Installation

You can get `contextcheck` by `go get` command.
Expand Down

0 comments on commit bb07f32

Please sign in to comment.