errmesscheck
Go linter that checks error message format.
supported package: https://github.com/pkg/errors
Motivation
We want to unify the format of error messages.
OK pattern🕺
failed to xxxxxxx.
NG pattern👮🏻
xxxxxxx failed.
Usage
package a
import (
"strconv"
"github.com/pkg/errors"
)
func Sample() error {
if _, err := strconv.Atoi("1"); err != nil {
return errors.Wrap(err, "failed to strconv.Atoi")
}
return nil
}
Analysis
$ errorsmescheck ./...
./a.go:11:10: The prefix of the error message should be 'failed to ...'
Installation
go install github.com/sho-hata/errmescheck/cmd/errmescheck@latest
Contribution
- Fork (https://github.com/sho-hata/errmescheck/fork)
- Create a feature branch
- Commit your changes
- Rebase your local changes against the master branch
- Run test suite with the go
test ./...
command and confirm that it passes
- Run
gofmt -s
- Create new Pull Request
License
MIT
Author
sho-hata