File tree Expand file tree Collapse file tree 3 files changed +54
-0
lines changed
pkg/golinters/gochecksumtype/testdata Expand file tree Collapse file tree 3 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,12 @@ func sumTypeTest() {
29
29
panic ("??" )
30
30
}
31
31
32
+ switch sum .(type ) {
33
+ case * One :
34
+ default :
35
+ log .Println ("legit catch all goes here" )
36
+ }
37
+
32
38
log .Println ("??" )
33
39
34
40
switch sum .(type ) {
Original file line number Diff line number Diff line change
1
+ //golangcitest:args -Egochecksumtype
2
+ //golangcitest:config_path testdata/gochecksumtype_custom.yml
3
+ package testdata
4
+
5
+ import (
6
+ "log"
7
+ )
8
+
9
+ //sumtype:decl
10
+ type SumType interface { isSumType () }
11
+
12
+ //sumtype:decl
13
+ type One struct {} // want "type 'One' is not an interface"
14
+
15
+ func (One ) isSumType () {}
16
+
17
+ type Two struct {}
18
+
19
+ func (Two ) isSumType () {}
20
+
21
+ func sumTypeTest () {
22
+ var sum SumType = One {}
23
+ switch sum .(type ) { // want "exhaustiveness check failed for sum type.*SumType.*missing cases for Two"
24
+ case One :
25
+ }
26
+
27
+ switch sum .(type ) { // want "exhaustiveness check failed for sum type.*SumType.*missing cases for Two"
28
+ case One :
29
+ default :
30
+ panic ("??" )
31
+ }
32
+
33
+ switch sum .(type ) { // want "exhaustiveness check failed for sum type.*SumType.*missing cases for Two"
34
+ case * One :
35
+ default :
36
+ log .Println ("legit catch all goes here" )
37
+ }
38
+
39
+ log .Println ("??" )
40
+
41
+ switch sum .(type ) {
42
+ case One :
43
+ case Two :
44
+ }
45
+ }
Original file line number Diff line number Diff line change
1
+ linters-settings :
2
+ gochecksumtype :
3
+ default-signifies-exhaustive : false
You can’t perform that action at this time.
0 commit comments