This doesn't change the existing restriction with disallows
spaces in import paths (as found in an import declaration).
It simply permits packages to be under a directory name that
may contain spaces.
Verified manually that it works. This could use a test, but the
change is trivial. We also can't use the existing test framework
(under test/) because the way those tests are run with test/run.go,
the mechanims for compiling a directory, even if it contains blanks
it its name, does't produce compiler paths with blanks
(the compilation is local).
Fixes #20306.
Change-Id: I6cbffb86c3394347897c3c94b110da0aadc5bfdf
Reviewed-on: https://go-review.googlesource.com/46001
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
}
// we should never see a bad import path
- if isbadimport(path) {
+ if isbadimport(path, true) {
p.formatErrorf("bad package path %q for package %s", path, name)
}
return nil
}
- if isbadimport(path_) {
+ if isbadimport(path_, false) {
return nil
}
}
path_ = path.Join(prefix, path_)
- if isbadimport(path_) {
+ if isbadimport(path_, true) {
return nil
}
}
"type",
}
-func isbadimport(path string) bool {
+func isbadimport(path string, allowSpace bool) bool {
if strings.Contains(path, "\x00") {
yyerror("import path contains NUL")
return true
return true
}
- if unicode.IsSpace(r) {
+ if !allowSpace && unicode.IsSpace(r) {
yyerror("import path contains space character: %q", path)
return true
}