github.com/serversong/goreporter@v0.0.0-20200325104552-3cfaf44fd178/linters/staticcheck/testdata/CheckRegexps.go (about)

     1  package pkg
     2  
     3  import (
     4  	"log"
     5  	"regexp"
     6  )
     7  
     8  const c1 = `[`
     9  const c2 = `abc`
    10  
    11  var re1 = regexp.MustCompile(`ab\yef`) // MATCH /error parsing regexp/
    12  var re2 = regexp.MustCompile(c1)       // MATCH /error parsing regexp/
    13  var re3 = regexp.MustCompile(c2)
    14  
    15  func fn() {
    16  	_, err := regexp.Compile(`foo(`) // MATCH /error parsing regexp/
    17  	if err != nil {
    18  		panic(err)
    19  	}
    20  	if re2.MatchString("foo(") {
    21  		log.Println("of course 'foo(' matches 'foo('")
    22  	}
    23  }