Skip to content

Commit d650608

Browse files
authored
Link up nilerror from the main README (#28)
Just makes it easier to catalog what's in this repository and get a quick explanation for `nilerror` without having to click all the way into it.
1 parent 741fb02 commit d650608

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
See:
66

77
* [`datadogriver`](../datadogriver): Package containing examples of using `otelriver` with [DataDog](https://www.datadoghq.com/).
8+
* [`nilerror`](../nilerror): Package containing a River hook for detecting a common accidental Go problem where a nil struct value is wrapped in a non-nil interface value.
89
* [`otelriver`](../otelriver): Package for use with [OpenTelemetry](https://opentelemetry.io/).

nilerror/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# nilerror [![Build Status](https://github.com/riverqueue/rivercontrib/actions/workflows/ci.yaml/badge.svg?branch=master)](https://github.com/riverqueue/rivercontrib/actions) [![Go Reference](https://pkg.go.dev/badge/github.com/riverqueue/rivercontrib.svg)](https://pkg.go.dev/github.com/riverqueue/rivercontrib/nilerror)
22

3-
Provides a River hook for detecting a common Go error where a nil struct value is wrapped in a non-nil interface value. This commonly causes trouble with the error interface, where an unintentional nil error is returned.
3+
Provides a River hook for detecting a common accidental Go problem where a nil struct value is wrapped in a non-nil interface value. This commonly causes trouble with the error interface, where an unintentional non-nil error is returned. For example:
4+
5+
``` go
6+
func returnsError() error {
7+
var p *MyError = nil
8+
if bad() {
9+
p = ErrBad
10+
}
11+
return p // Will always return a non-nil error.
12+
}
13+
```
414

515
See https://go.dev/doc/faq#nil_error.
616

0 commit comments

Comments
 (0)