1
- # exhaustive [ ![ Godoc] [ godoc-svg ]] [ repo ]
1
+ # exhaustive [ ![ Godoc] [ godoc-svg ]] [ godoc ]
2
2
3
3
Package exhaustive defines an analyzer that checks exhaustiveness of switch
4
4
statements of enum-like constants in Go source code. The analyzer can be
@@ -30,7 +30,7 @@ exhaustive [flags] [packages]
30
30
Given the enum:
31
31
32
32
``` go
33
- package token
33
+ package token // import "example.org/token"
34
34
35
35
type Token int
36
36
@@ -46,9 +46,9 @@ const (
46
46
and code that switches on the enum:
47
47
48
48
``` go
49
- package calc
49
+ package calc // import "example.org/calc"
50
50
51
- import " token"
51
+ import " example.org/ token"
52
52
53
53
func f (t token .Token ) {
54
54
switch t {
@@ -69,7 +69,7 @@ var m = map[token.Token]string{
69
69
running ` exhaustive ` with default options will print:
70
70
71
71
```
72
- $ exhaustive
72
+ $ exhaustive example.org/calc/...
73
73
calc.go:6:2: missing cases in switch of type token.Token: token.Quotient, token.Remainder
74
74
$
75
75
```
@@ -78,7 +78,7 @@ To additionally check exhaustiveness of map literal keys, use
78
78
` -check=switch,map ` :
79
79
80
80
```
81
- $ exhaustive -check=switch,map
81
+ $ exhaustive -check=switch,map example.org/calc/...
82
82
calc.go:6:2: missing cases in switch of type token.Token: token.Quotient, token.Remainder
83
83
calc.go:14:9: missing keys in map of key type token.Token: token.Quotient, token.Remainder
84
84
$
89
89
Issues and changes are welcome. Please discuss substantial changes
90
90
in an issue first.
91
91
92
- [ repo ] : https://pkg.go.dev/github.com/nishanths/exhaustive
92
+ [ godoc ] : https://pkg.go.dev/github.com/nishanths/exhaustive
93
93
[ godoc-svg ] : https://pkg.go.dev/badge/github.com/nishanths/exhaustive.svg
94
94
[ godoc-doc ] : https://pkg.go.dev/github.com/nishanths/exhaustive#section-documentation
95
95
[ xanalysis ] : https://pkg.go.dev/golang.org/x/tools/go/analysis
0 commit comments