github.com/songshiyun/revive@v1.1.5-0.20220323112655-f8433a19b3c5/testdata/string-format.go (about)

     1  // Test string literal regex checks
     2  
     3  package pkg
     4  
     5  func stringFormatMethod1(a, b string) {
     6  
     7  }
     8  
     9  func stringFormatMethod2(a, b string, c struct {
    10  	d string
    11  }) {
    12  
    13  }
    14  
    15  type stringFormatMethods struct{}
    16  
    17  func (s stringFormatMethods) Method3(a, b, c string) {
    18  
    19  }
    20  
    21  func stringFormat() {
    22  	stringFormatMethod1("This string is fine", "")
    23  	stringFormatMethod1("this string is not capitalized", "") // MATCH /must start with a capital letter/
    24  	stringFormatMethod2(s3, "", struct {
    25  		d string
    26  	}{
    27  		d: "This string is capitalized, but ends with a period."}) // MATCH /string literal doesn't match user defined regex /[^\.]$//
    28  	s := stringFormatMethods{}
    29  	s.Method3("", "", "This string starts with th") // MATCH /must not start with 'th'/
    30  }