mirror of
https://github.com/golang/go
synced 2024-11-26 11:28:21 -07:00
[dev.regabi] cmd/compile: initialize importMap lazily
This sets up the next CL, moving importMap to a global zeroed struct. Change-Id: I1acc91b440d3da6e28fb32bd275fb3cd36db4e97 Reviewed-on: https://go-review.googlesource.com/c/go/+/272046 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
7b144ed4f7
commit
5fd949e4bd
@ -877,11 +877,14 @@ func writebench(filename string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
importMap = map[string]string{}
|
importMap map[string]string
|
||||||
packageFile map[string]string // nil means not in use
|
packageFile map[string]string // nil means not in use
|
||||||
)
|
)
|
||||||
|
|
||||||
func addImportMap(s string) {
|
func addImportMap(s string) {
|
||||||
|
if importMap == nil {
|
||||||
|
importMap = make(map[string]string)
|
||||||
|
}
|
||||||
if strings.Count(s, "=") != 1 {
|
if strings.Count(s, "=") != 1 {
|
||||||
log.Fatal("-importmap argument must be of the form source=actual")
|
log.Fatal("-importmap argument must be of the form source=actual")
|
||||||
}
|
}
|
||||||
@ -894,6 +897,9 @@ func addImportMap(s string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func readImportCfg(file string) {
|
func readImportCfg(file string) {
|
||||||
|
if importMap == nil {
|
||||||
|
importMap = make(map[string]string)
|
||||||
|
}
|
||||||
packageFile = map[string]string{}
|
packageFile = map[string]string{}
|
||||||
data, err := ioutil.ReadFile(file)
|
data, err := ioutil.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user