Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
wangchunlu committed Sep 3, 2021
1 parent 5d76471 commit 4be28c8
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,35 @@

# contextcheck

`contextcheck` is a static analysis tool which checks whether use context.Background() and context.TODO() directly.
`contextcheck` is a static analysis tool, it is used to check a function whether use context.Background() or context.TODO() directly instead of the input ctx when calling the sub-function, or even don't pass the ctx, which will result in a broken call link.

## Install
For example:

```go
func call1(ctx context.Context) {
...
call2(context.Background()) // should use ctx

call3() // should pass the ctx
...
}

func call2(ctx context.Context) {
...
}

func call3() {
ctx := context.TODO()
call2(ctx)
}
```

## Installation

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

```bash
$ go get -u github.com/jingyugao/rowserrcheck
$ go get -u github.com/sylvia7788/contextcheck
```

or build yourself.
Expand All @@ -21,9 +42,11 @@ $ make install
```

## Usage

Invoke `contextcheck` with your package name
```
contextcheck ./...
# or
contextcheck github.com/you/yourproject/...

```bash
$ contextcheck ./...
$ # or
$ contextcheck github.com/you/yourproject/...
```

0 comments on commit 4be28c8

Please sign in to comment.