-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
99 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) 2013 The Go Authors. All rights reserved. | ||
// Source: https://github.com/golang/lint/blob/master/testdata/errors.go | ||
// Test for naming errors. | ||
|
||
// Package foo ... | ||
package foo | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
) | ||
|
||
var unexp = errors.New("some unexported error") // MATCH /error var.*unexp.*errFoo/ | ||
|
||
// Exp ... | ||
var Exp = errors.New("some exported error") // MATCH /error var.*Exp.*ErrFoo/ | ||
|
||
var ( | ||
e1 = fmt.Errorf("blah %d", 4) // MATCH /error var.*e1.*errFoo/ | ||
// E2 ... | ||
E2 = fmt.Errorf("blah %d", 5) // MATCH /error var.*E2.*ErrFoo/ | ||
) | ||
|
||
func f() { | ||
var whatever = errors.New("ok") // ok | ||
_ = whatever | ||
} | ||
|
||
// Check for the error strings themselves. | ||
|
||
func g(x int) error { | ||
if x < 1 { | ||
return fmt.Errorf("This %d is too low", x) // MATCH /error strings.*not be capitalized/ | ||
} else if x == 0 { | ||
return fmt.Errorf("XML time") // ok | ||
} | ||
return errors.New(`too much stuff.`) // MATCH /error strings.*not end with punctuation/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Package foo ... | ||
package foo | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters