-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Description
by ZhaoChengbing87:
Before filing a bug, please check whether it has been fixed since the latest release. Search the issue tracker and check that you're running the latest version of Go: Run "go version" and compare against http://golang.org/doc/devel/release.html If a newer version of Go exists, install it and retry what you did to reproduce the problem. Thanks. What does 'go version' print? What steps reproduce the problem? If possible, include a link to a program on play.golang.org. 1. go version go1.2 linux/amd64 2. init the regexp.Regexp with a empty string 3. post the code here package main import ( "fmt" "regexp" ) var ( //fileRegexp = `chat.log` fileRegexp string reg = regexp.MustCompile(fileRegexp) ) func main() { fileRegexp = `chat.log` var teststring = []string{"chat.log", "a", "b", "c", "not_match"} for _, testcase := range teststring { if reg.MatchString(testcase) { fmt.Println(testcase, "matches", fileRegexp) } } } What happened? we get answers like chat.log matches chat.log a matches chat.log b matches chat.log c matches chat.log not_match matches chat.log It is obviously wrong here. What should have happened instead? the programme should panic or report a compile error here. Please provide any additional information below. No additional information needed.