gitee.com/lonely0422/gometalinter.git@v3.0.1-0.20190307123442-32416ab75314+incompatible/regressiontests/gochecknoinits_test.go (about)

     1  package regressiontests
     2  
     3  import "testing"
     4  
     5  func TestGochecknoinits(t *testing.T) {
     6  	t.Parallel()
     7  	source := `package test
     8  
     9  	var variable = 1
    10  
    11  	type S struct {}
    12  
    13  	func (s S) init() {}
    14  
    15  	func main() {
    16  		init := func() {}
    17  		init()
    18  	}
    19  
    20  	func init() {}
    21  `
    22  	expected := Issues{
    23  		{Linter: "gochecknoinits", Severity: "warning", Path: "test.go", Line: 14, Message: "init function"},
    24  	}
    25  	ExpectIssues(t, "gochecknoinits", source, expected)
    26  }