www.github.com/golangci/golangci-lint.git@v1.10.1/test/testdata/goconst.go (about)

     1  // args: -Egoconst
     2  package testdata
     3  
     4  import "fmt"
     5  
     6  func GoconstA() {
     7  	a := "needconst" // ERROR "string `needconst` has 5 occurrences, make it a constant"
     8  	fmt.Print(a)
     9  	b := "needconst"
    10  	fmt.Print(b)
    11  	c := "needconst"
    12  	fmt.Print(c)
    13  }
    14  
    15  func GoconstB() {
    16  	a := "needconst"
    17  	fmt.Print(a)
    18  	b := "needconst"
    19  	fmt.Print(b)
    20  }
    21  
    22  const AlreadyHasConst = "alreadyhasconst"
    23  
    24  func GoconstC() {
    25  	a := "alreadyhasconst" // ERROR "string `alreadyhasconst` has 3 occurrences, but such constant `AlreadyHasConst` already exists"
    26  	fmt.Print(a)
    27  	b := "alreadyhasconst"
    28  	fmt.Print(b)
    29  	c := "alreadyhasconst"
    30  	fmt.Print(c)
    31  }