Skip to content

Commit

Permalink
README: fix assumptions after refactoring, that enables some features (
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonboom authored Oct 4, 2024
1 parent 8b08ccd commit b1f6e09
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 24 deletions.
26 changes: 2 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var ErrInvalidURL = errors.New("invalid url") // or errInvalidURL

More examples in [tests](https://github.com/Antonboom/errname/blob/master/pkg/analyzer/facts_test.go).

## Assumptions (open to contributors 🙏🏻)
## Assumptions

<details>
<summary>Click to expand</summary>
Expand Down Expand Up @@ -111,28 +111,6 @@ func NewDecodeError() error {
}
```

- Package aliases are not supported if the source package and its directory differ in name.

- Nested error types are not supported

```go
type timeoutErr struct { // no warning from the linter :(
error
}

type DeadlineErr struct { // no warning from the linter :(
timeoutErr
}
```

- Not supported sentinel errors that were created by an external type or func (except `errors`/`fmt`) and that do not
have an explicit type `error`:

```go
var ErrUnsupported = new(net.AddrError)
var ErrSupported error = new(net.AddrError)
```

- Linter only checks the correctness of the suffix and prefix and their **uniqueness**. The logical meaning of the
identifier remains on the developer's conscience:

Expand All @@ -145,7 +123,7 @@ var ErrExecQuery = errors.New("exec query error")
var ErrGdfjnskjdfskf = errors.New("strange error") // on the developer's conscience
```

- For error types over array/slice the `Errors` suffix is expected:
- For error types over array/slice the `Errors` suffix is also allowed:

```go
// Bad.
Expand Down
8 changes: 8 additions & 0 deletions pkg/analyzer/testdata/src/regular/error_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ type (
)

func (s *SomeTypeWithPtr) Error() string { return "SomeTypeWithPtr" }

type timeoutErr struct { // want "the error type name `timeoutErr` should conform to the `xxxError` format"
error
}

type DeadlineErr struct { // want "the error type name `DeadlineErr` should conform to the `XxxError` format"
timeoutErr
}

0 comments on commit b1f6e09

Please sign in to comment.