• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..27-Sep-2021-

.gitignoreH A D27-Sep-2021269 1612

.golangci.ymlH A D27-Sep-20215.2 KiB150129

.travis.ymlH A D27-Sep-2021535 2519

LICENSEH A D27-Sep-20211 KiB2217

README.adocH A D27-Sep-20212.5 KiB7553

comparison.goH A D27-Sep-20212.5 KiB12495

definition.goH A D27-Sep-20211.4 KiB7557

err113.goH A D27-Sep-20211.7 KiB9168

README.adoc

1= err113 image:https://godoc.org/github.com/Djarvur/go-err113?status.svg["GoDoc",link="http://godoc.org/github.com/Djarvur/go-err113"] image:https://travis-ci.org/Djarvur/go-err113.svg["Build Status",link="https://travis-ci.org/Djarvur/go-err113"] image:https://coveralls.io/repos/Djarvur/go-err113/badge.svg?branch=master&service=github["Coverage Status",link="https://coveralls.io/github/Djarvur/go-err113?branch=master"]
2Daniel Podolsky
3:toc:
4
5Golang linter to check the errors handling expressions
6
7== Details
8
9Starting from Go 1.13 the standard `error` type behaviour was changed: one `error` could be derived from another with `fmt.Errorf()` method using `%w` format specifier.
10
11So the errors hierarchy could be built for flexible and responsible errors processing.
12
13And to make this possible at least two simple rules should be followed:
14
151. `error` values should not be compared directly but with `errors.Is()` method.
161. `error` should not be created dynamically from scratch but by the wrapping the static (package-level) error.
17
18This linter is checking the code for these 2 rules compliance.
19
20=== Reports
21
22So, `err113` reports every `==` and `!=` comparison for exact `error` type variables except comparison to `nil` and `io.EOF`.
23
24Also, any call of `errors.New()` and `fmt.Errorf()` methods are reported except the calls used to initialise package-level variables and the `fmt.Errorf()` calls wrapping the other errors.
25
26Note: non-standard packages, like `github.com/pkg/errors` are ignored completely.
27
28== Install
29
30```
31go get -u github.com/Djarvur/go-err113/cmd/err113
32```
33
34== Usage
35
36Defined by link:https://pkg.go.dev/golang.org/x/tools/go/analysis/singlechecker[singlechecker] package.
37
38```
39err113: checks the error handling rules according to the Go 1.13 new error type
40
41Usage: err113 [-flag] [package]
42
43
44Flags:
45  -V	print version and exit
46  -all
47    	no effect (deprecated)
48  -c int
49    	display offending line with this many lines of context (default -1)
50  -cpuprofile string
51    	write CPU profile to this file
52  -debug string
53    	debug flags, any subset of "fpstv"
54  -fix
55    	apply all suggested fixes
56  -flags
57    	print analyzer flags in JSON
58  -json
59    	emit JSON output
60  -memprofile string
61    	write memory profile to this file
62  -source
63    	no effect (deprecated)
64  -tags string
65    	no effect (deprecated)
66  -trace string
67    	write trace log to this file
68  -v	no effect (deprecated)
69```
70
71== Thanks
72
73To link:https://github.com/quasilyte[Iskander (Alex) Sharipov] for the really useful advices.
74
75To link:https://github.com/jackwhelpton[Jack Whelpton] for the bugfix provided.