diff options
author | Ayke van Laethem <[email protected]> | 2021-01-21 15:38:15 +0100 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-01-21 19:06:02 +0100 |
commit | 36db75b36680d36d0fbbc0b8c876ebb49abd2fb3 (patch) | |
tree | e61759effbbc2c5e637c1157b4b6038503d871f5 /loader/loader.go | |
parent | a5e2b278844627bd55e1e72099c654d724130fb7 (diff) | |
download | tinygo-36db75b36680d36d0fbbc0b8c876ebb49abd2fb3.tar.gz tinygo-36db75b36680d36d0fbbc0b8c876ebb49abd2fb3.zip |
loader: support imports from vendor directories
This fixes https://github.com/tinygo-org/tinygo/issues/1518.
Diffstat (limited to 'loader/loader.go')
-rw-r--r-- | loader/loader.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/loader/loader.go b/loader/loader.go index d25b08a91..28f969e5c 100644 --- a/loader/loader.go +++ b/loader/loader.go @@ -52,7 +52,8 @@ type PackageJSON struct { CFiles []string // Dependency information - Imports []string + Imports []string + ImportMap map[string]string // Error information Error *struct { @@ -411,6 +412,9 @@ func (p *Package) Import(to string) (*types.Package, error) { if to == "unsafe" { return types.Unsafe, nil } + if newTo, ok := p.ImportMap[to]; ok && !strings.HasSuffix(newTo, ".test]") { + to = newTo + } if imported, ok := p.program.Packages[to]; ok { return imported.Pkg, nil } else { |