Skip to content

Commit 36db75b

Browse files
aykevldeadprogram
authored andcommitted
loader: support imports from vendor directories
This fixes #1518.
1 parent a5e2b27 commit 36db75b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

loader/loader.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ type PackageJSON struct {
5252
CFiles []string
5353

5454
// Dependency information
55-
Imports []string
55+
Imports []string
56+
ImportMap map[string]string
5657

5758
// Error information
5859
Error *struct {
@@ -411,6 +412,9 @@ func (p *Package) Import(to string) (*types.Package, error) {
411412
if to == "unsafe" {
412413
return types.Unsafe, nil
413414
}
415+
if newTo, ok := p.ImportMap[to]; ok && !strings.HasSuffix(newTo, ".test]") {
416+
to = newTo
417+
}
414418
if imported, ok := p.program.Packages[to]; ok {
415419
return imported.Pkg, nil
416420
} else {

0 commit comments

Comments
 (0)