From 98c374dcad22caddb52ea2a38394a4158a1de0c4 Mon Sep 17 00:00:00 2001 From: SalvadorC Date: Wed, 28 Jul 2021 16:59:55 +0200 Subject: [PATCH] add tests on common methods handling (#548) --- testdata/golint/exported.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/testdata/golint/exported.go b/testdata/golint/exported.go index 1ed5002..f43a545 100644 --- a/testdata/golint/exported.go +++ b/testdata/golint/exported.go @@ -1,6 +1,8 @@ // Package golint comment package golint +import "net/http" + type ( // O is a shortcut (alias) for map[string]interface{}, e.g. a JSON object. O = map[string]interface{} @@ -33,3 +35,21 @@ func Toto2() {} /*SecondLetter something */ const SecondLetter = "B" + +// Tests for common method names +//// Should NOT fail for methods +func (_) Error() string { return "" } +func (_) String() string { return "" } +func (_) ServeHTTP(w http.ResponseWriter, r *http.Request) {} +func (_) Read(p []byte) (n int, err error) { return 0, nil } +func (_) Write(p []byte) (n int, err error) { return 0, nil } +func (_) Unwrap(err error) error { return nil } + +//// Should fail for functions + +func Error() string { return "" } // MATCH /exported function Error should have comment or be unexported/ +func String() string { return "" } // MATCH /exported function String should have comment or be unexported/ +func ServeHTTP(w http.ResponseWriter, r *http.Request) {} // MATCH /exported function ServeHTTP should have comment or be unexported/ +func Read(p []byte) (n int, err error) { return 0, nil } // MATCH /exported function Read should have comment or be unexported/ +func Write(p []byte) (n int, err error) { return 0, nil } // MATCH /exported function Write should have comment or be unexported/ +func Unwrap(err error) error { return nil } // MATCH /exported function Unwrap should have comment or be unexported/