There are fewer special cases this way: the import map applies
to all import paths, not just the ones not spelled "unsafe".
This is also consistent with what the code in cmd/go and go/build expects.
They make no exception for "unsafe".
For #13703.
Change-Id: I622295261ca35a6c1e83e8508d363bddbddb6c0a
Reviewed-on: https://go-review.googlesource.com/18438
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
errorexit()
}
- if f.U.(string) == "unsafe" {
+ path_ := f.U.(string)
+
+ if mapped, ok := importMap[path_]; ok {
+ path_ = mapped
+ }
+
+ if path_ == "unsafe" {
if safemode != 0 {
Yyerror("cannot import package unsafe")
errorexit()
return
}
- path_ := f.U.(string)
-
- if mapped, ok := importMap[path_]; ok {
- path_ = mapped
- }
-
if islocalname(path_) {
if path_[0] == '/' {
Yyerror("import path cannot be absolute path")