Skip to content

Commit 8587396

Browse files
MichaelUrmanpolyfloyd
authored andcommitted
Add clarifying example to test CompareSwitch
1 parent b4e7a38 commit 8587396

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

errorlint/testdata/src/errorsis/errorsis.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,14 @@ func NotEqualOperatorYoda() {
7777
func CompareSwitch() {
7878
err := doThing()
7979
switch err { // want `switch on an error will fail on wrapped errors. Use errors.Is to check for specific errors`
80+
case nil:
81+
fmt.Println("nil")
8082
case ErrFoo:
8183
fmt.Println("ErrFoo")
8284
}
8385
}
8486

85-
func CompareSwitchNilDefault() {
87+
func CompareSwitchSafe() {
8688
err := doThing()
8789
switch err {
8890
case nil:

0 commit comments

Comments
 (0)