@@ -16,7 +16,6 @@ import (
|
||||
"io"
|
||||
"math/big"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
@@ -167,8 +166,8 @@ func (e *Extractor) genContent(importPath string, p *types.Package) ([]byte, err
|
||||
continue
|
||||
}
|
||||
|
||||
pname := path.Base(importPath) + "." + name
|
||||
if rname := path.Base(importPath) + name; restricted[rname] {
|
||||
pname := p.Name() + "." + name
|
||||
if rname := p.Name() + name; restricted[rname] {
|
||||
// Restricted symbol, locally provided by stdlib wrapper.
|
||||
pname = rname
|
||||
}
|
||||
|
||||
@@ -78,6 +78,13 @@ func TestPackages(t *testing.T) {
|
||||
importPath: "guthib.com/baz",
|
||||
expected: expectedOutput,
|
||||
},
|
||||
{
|
||||
desc: "using relative path, package name is not same as import path",
|
||||
wd: "./testdata/6/src/guthib.com/bar",
|
||||
arg: "../baz-baz",
|
||||
importPath: "guthib.com/baz",
|
||||
expected: expectedOutput,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
|
||||
9
extract/testdata/6/src/guthib.com/bar/main.go
vendored
Normal file
9
extract/testdata/6/src/guthib.com/bar/main.go
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"guthib.com/baz"
|
||||
)
|
||||
|
||||
func main() {
|
||||
baz.Hello()
|
||||
}
|
||||
5
extract/testdata/6/src/guthib.com/baz-baz/baz.go
vendored
Normal file
5
extract/testdata/6/src/guthib.com/baz-baz/baz.go
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
package baz
|
||||
|
||||
func Hello() {
|
||||
println("HELLO")
|
||||
}
|
||||
1
extract/testdata/6/src/guthib.com/baz-baz/go.mod
vendored
Normal file
1
extract/testdata/6/src/guthib.com/baz-baz/go.mod
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module guthib.com/baz-baz
|
||||
Reference in New Issue
Block a user