Skip to content

Commit

Permalink
Add Example
Browse files Browse the repository at this point in the history
  • Loading branch information
jjti committed Dec 28, 2023
1 parent 45c93d5 commit 181e6f1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@ go install github.com/jjti/go-spancheck/cmd/spancheck@latest
spancheck ./...
```

## Example

```go
func _() error {
// span.End is not called on all paths, possible memory leak
// span.SetStatus is not called on all paths
// span.RecordError is not called on all paths
_, span := otel.Tracer("foo").Start(context.Background(), "bar")

if true {
// return can be reached without calling span.End
// return can be reached without calling span.SetStatus
// return can be reached without calling span.RecordError
return errors.New("err")
}

return nil // return can be reached without calling span.End
}
```

## Configuration

Only the `span.End()` check is enabled by default. The others can be enabled with `-enable-all`, `-enable-record-error-check`, or `-enable-set-status-check`.
Expand Down

0 comments on commit 181e6f1

Please sign in to comment.