diff --git a/README.md b/README.md index bff1722..6f74446 100644 --- a/README.md +++ b/README.md @@ -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`.