You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In src/cmd/go/pkg.go function vendoredImportPath
When we use "go test myapp_test.go", parent.ImportPath is "command-line-arguments", and it will panic in return parent.ImportPath[:len(parent.ImportPath)-chopped] + "/" + vpath, because of
len(parent.ImportPath)-chopped < 0
I add some code to fix this.
targ := filepath.Join(dir[:i], vpath)
if isDir(targ) && hasGoFiles(targ) {
+ if parent.ImportPath == "command-line-arguments" {
+ if i == len(root) {
+ return vpath
+ }
+ return dir[len(root)+1:i] + "/" + vpath
+ }
// We started with parent's dir c:\gopath\src\foo\bar\baz\quux\xyzzy.
// We know the import path for parent's dir.
// We chopped off some number of path elements and
// added vendor\path to produce c:\gopath\src\foo\bar\baz\vendor\path.
// Now we want to know the import path for that directory.
// Construct it by chopping the same number of path elements
// (actually the same number of bytes) from parent's import path
// and then append /vendor/path.
chopped := len(dir) - i
if chopped == len(parent.ImportPath)+1 {
// We walked up from c:\gopath\src\foo\bar
// and found c:\gopath\src\vendor\path.
// We chopped \foo\bar (length 8) but the import path is "foo/bar" (length 7).
// Use "vendor/path" without any prefix.
return vpath
}
return parent.ImportPath[:len(parent.ImportPath)-chopped] + "/" + vpath
}
The text was updated successfully, but these errors were encountered:
go1.6 centos7
file:
src/vendor/mylibtesttest/myapp/myapp_test.go
file:
src/vendor/mylibtesttest/rds/rds.go
In
src/vendor/mylibtesttest/myapp/
1.
go test
go test myapp_test.go
In
src/cmd/go/pkg.go
functionvendoredImportPath
When we use "go test myapp_test.go", parent.ImportPath is "command-line-arguments", and it will panic in
return parent.ImportPath[:len(parent.ImportPath)-chopped] + "/" + vpath
, because oflen(parent.ImportPath)-chopped < 0
I add some code to fix this.
The text was updated successfully, but these errors were encountered: