compiler: add go test command
This commit is contained in:
@@ -58,6 +58,8 @@ const (
|
||||
NeedTypesSizes = packages.NeedTypesSizes
|
||||
NeedTypesInfo = packages.NeedTypesInfo
|
||||
|
||||
NeedForTest = packages.NeedForTest
|
||||
|
||||
typecheckCgo = NeedModule - 1 // TODO(xsw): how to check
|
||||
)
|
||||
|
||||
@@ -129,18 +131,18 @@ func (p Deduper) SetPkgPath(fn func(path, name string) string) {
|
||||
p.setpath = fn
|
||||
}
|
||||
|
||||
func (p Deduper) Check(pkgPath string) *Cached {
|
||||
if v, ok := p.cache.Load(pkgPath); ok {
|
||||
func (p Deduper) Check(id string) *Cached {
|
||||
if v, ok := p.cache.Load(id); ok {
|
||||
return v.(*Cached)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p Deduper) set(pkgPath string, cp *Cached) {
|
||||
func (p Deduper) set(id string, cp *Cached) {
|
||||
if DebugPackagesLoad {
|
||||
log.Println("==> Import", pkgPath)
|
||||
log.Println("==> Import", id)
|
||||
}
|
||||
p.cache.Store(pkgPath, cp)
|
||||
p.cache.Store(id, cp)
|
||||
}
|
||||
|
||||
//go:linkname defaultDriver golang.org/x/tools/go/packages.defaultDriver
|
||||
@@ -176,7 +178,7 @@ func loadPackageEx(dedup Deduper, ld *loader, lpkg *loaderPackage) {
|
||||
}
|
||||
|
||||
if dedup != nil {
|
||||
if cp := dedup.Check(lpkg.PkgPath); cp != nil {
|
||||
if cp := dedup.Check(lpkg.ID); cp != nil {
|
||||
lpkg.Types = cp.Types
|
||||
lpkg.Fset = ld.Fset
|
||||
lpkg.TypesInfo = cp.TypesInfo
|
||||
|
||||
Reference in New Issue
Block a user