Skip to content

Commit 98c374d

Browse files
authored
add tests on common methods handling (#548)
1 parent 7dde483 commit 98c374d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

testdata/golint/exported.go

+20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Package golint comment
22
package golint
33

4+
import "net/http"
5+
46
type (
57
// O is a shortcut (alias) for map[string]interface{}, e.g. a JSON object.
68
O = map[string]interface{}
@@ -33,3 +35,21 @@ func Toto2() {}
3335

3436
/*SecondLetter something */
3537
const SecondLetter = "B"
38+
39+
// Tests for common method names
40+
//// Should NOT fail for methods
41+
func (_) Error() string { return "" }
42+
func (_) String() string { return "" }
43+
func (_) ServeHTTP(w http.ResponseWriter, r *http.Request) {}
44+
func (_) Read(p []byte) (n int, err error) { return 0, nil }
45+
func (_) Write(p []byte) (n int, err error) { return 0, nil }
46+
func (_) Unwrap(err error) error { return nil }
47+
48+
//// Should fail for functions
49+
50+
func Error() string { return "" } // MATCH /exported function Error should have comment or be unexported/
51+
func String() string { return "" } // MATCH /exported function String should have comment or be unexported/
52+
func ServeHTTP(w http.ResponseWriter, r *http.Request) {} // MATCH /exported function ServeHTTP should have comment or be unexported/
53+
func Read(p []byte) (n int, err error) { return 0, nil } // MATCH /exported function Read should have comment or be unexported/
54+
func Write(p []byte) (n int, err error) { return 0, nil } // MATCH /exported function Write should have comment or be unexported/
55+
func Unwrap(err error) error { return nil } // MATCH /exported function Unwrap should have comment or be unexported/

0 commit comments

Comments
 (0)