Commit 93ad7022 authored by Ian Lance Taylor's avatar Ian Lance Taylor

cmd/go: use internal/goroot to check for a standard library package

Change-Id: I739728f976162a0b8425a93666e3694d967dceb7
Reviewed-on: https://go-review.googlesource.com/137436
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent b83ef36d
......@@ -14,6 +14,7 @@ import (
"cmd/go/internal/search"
"encoding/hex"
"fmt"
"internal/goroot"
"os"
"path/filepath"
"strings"
......@@ -30,13 +31,11 @@ func isStandardImportPath(path string) bool {
func findStandardImportPath(path string) string {
if search.IsStandardImportPath(path) {
dir := filepath.Join(cfg.GOROOT, "src", path)
if _, err := os.Stat(dir); err == nil {
return dir
if goroot.IsStandardPackage(cfg.GOROOT, cfg.BuildContext.Compiler, path) {
return filepath.Join(cfg.GOROOT, "src", path)
}
dir = filepath.Join(cfg.GOROOT, "src/vendor", path)
if _, err := os.Stat(dir); err == nil {
return dir
if goroot.IsStandardPackage(cfg.GOROOT, cfg.BuildContext.Compiler, "vendor/"+path) {
return filepath.Join(cfg.GOROOT, "src/vendor", path)
}
}
return ""
......
......@@ -9,6 +9,7 @@ import (
"errors"
"fmt"
"go/build"
"internal/goroot"
"os"
"path/filepath"
"strings"
......@@ -60,8 +61,8 @@ func Import(path string) (m module.Version, dir string, err error) {
if strings.HasPrefix(path, "golang_org/") {
return module.Version{}, filepath.Join(cfg.GOROOT, "src/vendor", path), nil
}
dir := filepath.Join(cfg.GOROOT, "src", path)
if _, err := os.Stat(dir); err == nil {
if goroot.IsStandardPackage(cfg.GOROOT, cfg.BuildContext.Compiler, path) {
dir := filepath.Join(cfg.GOROOT, "src", path)
return module.Version{}, dir, nil
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment