// !cgo (if cgo is disabled)
// tag (if tag is listed in ctxt.BuildTags)
// !tag (if tag is not listed in ctxt.BuildTags)
-// a slash-separated list of any of these
+// a comma-separated list of any of these
//
func (ctxt *Context) match(name string) bool {
if name == "" {
return false
}
if strings.HasPrefix(name, "!") { // negation
- return !ctxt.match(name[1:])
+ return len(name) > 1 && !ctxt.match(name[1:])
}
// Tags must be letters, digits, underscores.
- // Unlike in Go identifiers, all digits is fine (e.g., "386").
+ // Unlike in Go identifiers, all digits are fine (e.g., "386").
for _, c := range name {
if !unicode.IsLetter(c) && !unicode.IsDigit(c) && c != '_' {
return false
nomatch(runtime.GOOS + "," + runtime.GOARCH + ",!foo")
match(runtime.GOOS + "," + runtime.GOARCH + ",!bar")
nomatch(runtime.GOOS + "," + runtime.GOARCH + ",bar")
+ nomatch("!")
}
func TestDotSlashImport(t *testing.T) {