github.com/chenfeining/golangci-lint@v1.0.2-0.20230730162517-14c6c67868df/test/testdata/goconst_dont_ignore_test.go (about)

     1  //golangcitest:args -Egoconst
     2  //golangcitest:config_path testdata/configs/goconst_dont_ignore.yml
     3  package testdata
     4  
     5  import (
     6  	"fmt"
     7  	"testing"
     8  )
     9  
    10  func TestGoConstA(t *testing.T) {
    11  	a := "needconst" // want "string `needconst` has 5 occurrences, make it a constant"
    12  	fmt.Print(a)
    13  	b := "needconst"
    14  	fmt.Print(b)
    15  	c := "needconst"
    16  	fmt.Print(c)
    17  }
    18  
    19  func TestGoConstB(t *testing.T) {
    20  	a := "needconst"
    21  	fmt.Print(a)
    22  	b := "needconst"
    23  	fmt.Print(b)
    24  }
    25  
    26  const AlreadyHasConst = "alreadyhasconst"
    27  
    28  func TestGoConstC(t *testing.T) {
    29  	a := "alreadyhasconst" // want "string `alreadyhasconst` has 3 occurrences, but such constant `AlreadyHasConst` already exists"
    30  	fmt.Print(a)
    31  	b := "alreadyhasconst"
    32  	fmt.Print(b)
    33  	c := "alreadyhasconst"
    34  	fmt.Print(c)
    35  	fmt.Print("alreadyhasconst")
    36  }