github.com/golangci/go-tools@v0.0.0-20190318060251-af6baa5dc196/stylecheck/testdata/src/CheckErrorStrings/CheckErrorStrings.go (about) 1 // Package pkg ... 2 package pkg 3 4 import "errors" 5 6 func fn() { 7 errors.New("a perfectly fine error") 8 errors.New("Not a great error") // MATCH "error strings should not be capitalized" 9 errors.New("also not a great error.") // MATCH "error strings should not end with punctuation or a newline" 10 errors.New("URL is okay") 11 errors.New("SomeFunc is okay") 12 errors.New("URL is okay, but the period is not.") // MATCH "error strings should not end with punctuation or a newline" 13 } 14 15 func Write() { 16 errors.New("Write: this is broken") 17 } 18 19 type T struct{} 20 21 func (T) Read() { 22 errors.New("Read: this is broken") 23 errors.New("Read failed") 24 } 25 26 func fn2() { 27 // The error string hasn't to be in the same function 28 errors.New("Read failed") 29 }