github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/stylecheck/st1003/testdata/src/example.com/CheckNames/CheckNames.go (about)

     1  // Package pkg_foo ...
     2  package pkg_foo //@ diag(`should not use underscores in package names`)
     3  
     4  import _ "unsafe"
     5  
     6  var range_ int
     7  var _abcdef int
     8  var abcdef_ int
     9  var abc_def int  //@ diag(`should not use underscores in Go names; var abc_def should be abcDef`)
    10  var abc_def_ int //@ diag(`should not use underscores in Go names; var abc_def_ should be abcDef_`)
    11  
    12  func fn_1()  {} //@ diag(`func fn_1 should be fn1`)
    13  func fn2()   {}
    14  func fn_Id() {} //@ diag(`func fn_Id should be fnID`)
    15  func fnId()  {} //@ diag(`func fnId should be fnID`)
    16  
    17  var FOO_BAR int //@ diag(`should not use ALL_CAPS in Go names; use CamelCase instead`)
    18  var Foo_BAR int //@ diag(`var Foo_BAR should be FooBAR`)
    19  var foo_bar int //@ diag(`foo_bar should be fooBar`)
    20  var kFoobar int // not a check we inherited from golint. more false positives than true ones.
    21  
    22  var _1000 int // issue 858
    23  
    24  func fn(x []int) {
    25  	var (
    26  		a_b = 1 //@ diag(`var a_b should be aB`)
    27  		c_d int //@ diag(`var c_d should be cD`)
    28  	)
    29  	a_b += 2
    30  	for e_f := range x { //@ diag(`range var e_f should be eF`)
    31  		_ = e_f
    32  	}
    33  
    34  	_ = a_b
    35  	_ = c_d
    36  }
    37  
    38  //export fn_3
    39  func fn_3() {}
    40  
    41  //export not actually the export keyword
    42  func fn_4() {} //@ diag(`func fn_4 should be fn4`)
    43  
    44  //export
    45  func fn_5() {} //@ diag(`func fn_5 should be fn5`)
    46  
    47  // export fn_6
    48  func fn_6() {} //@ diag(`func fn_6 should be fn6`)
    49  
    50  //export fn_8
    51  func fn_7() {} //@ diag(`func fn_7 should be fn7`)
    52  
    53  //go:linkname fn_8 time.Now
    54  func fn_8() {}