Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README: fix assumptions after refactoring, that enables some features #48

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading