diff --git a/internal/wire/testdata/BuildTagsMainOnly/foo/wire.go b/internal/wire/testdata/BuildTagsMainOnly/foo/wire.go index 70b68af..4f5bec6 100644 --- a/internal/wire/testdata/BuildTagsMainOnly/foo/wire.go +++ b/internal/wire/testdata/BuildTagsMainOnly/foo/wire.go @@ -17,8 +17,7 @@ package main import ( - "bar" - + "example.com/bar" "github.com/google/go-cloud/wire" ) diff --git a/internal/wire/testdata/BuildTagsMainOnly/pkg b/internal/wire/testdata/BuildTagsMainOnly/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/BuildTagsMainOnly/pkg +++ b/internal/wire/testdata/BuildTagsMainOnly/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/BuildTagsRelativePkg/foo/wire.go b/internal/wire/testdata/BuildTagsRelativePkg/foo/wire.go index 70b68af..4f5bec6 100644 --- a/internal/wire/testdata/BuildTagsRelativePkg/foo/wire.go +++ b/internal/wire/testdata/BuildTagsRelativePkg/foo/wire.go @@ -17,8 +17,7 @@ package main import ( - "bar" - + "example.com/bar" "github.com/google/go-cloud/wire" ) diff --git a/internal/wire/testdata/BuildTagsRelativePkg/pkg b/internal/wire/testdata/BuildTagsRelativePkg/pkg index b10f96c..6b704cd 100644 --- a/internal/wire/testdata/BuildTagsRelativePkg/pkg +++ b/internal/wire/testdata/BuildTagsRelativePkg/pkg @@ -1 +1 @@ -./foo +./example.com/foo diff --git a/internal/wire/testdata/Chain/pkg b/internal/wire/testdata/Chain/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/Chain/pkg +++ b/internal/wire/testdata/Chain/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/Cleanup/pkg b/internal/wire/testdata/Cleanup/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/Cleanup/pkg +++ b/internal/wire/testdata/Cleanup/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/CopyOtherDecls/pkg b/internal/wire/testdata/CopyOtherDecls/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/CopyOtherDecls/pkg +++ b/internal/wire/testdata/CopyOtherDecls/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/Cycle/pkg b/internal/wire/testdata/Cycle/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/Cycle/pkg +++ b/internal/wire/testdata/Cycle/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/EmptyVar/pkg b/internal/wire/testdata/EmptyVar/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/EmptyVar/pkg +++ b/internal/wire/testdata/EmptyVar/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/ExportedValue/foo/wire.go b/internal/wire/testdata/ExportedValue/foo/wire.go index ea0bb83..e51f468 100644 --- a/internal/wire/testdata/ExportedValue/foo/wire.go +++ b/internal/wire/testdata/ExportedValue/foo/wire.go @@ -17,7 +17,7 @@ package main import ( - "bar" + "example.com/bar" "github.com/google/go-cloud/wire" ) diff --git a/internal/wire/testdata/ExportedValue/pkg b/internal/wire/testdata/ExportedValue/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/ExportedValue/pkg +++ b/internal/wire/testdata/ExportedValue/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/ExportedValue/want/wire_gen.go b/internal/wire/testdata/ExportedValue/want/wire_gen.go index 241c560..a340ecb 100644 --- a/internal/wire/testdata/ExportedValue/want/wire_gen.go +++ b/internal/wire/testdata/ExportedValue/want/wire_gen.go @@ -6,7 +6,7 @@ package main import ( - bar "bar" + bar "example.com/bar" ) // Injectors from wire.go: diff --git a/internal/wire/testdata/ExportedValueDifferentPackage/foo/wire.go b/internal/wire/testdata/ExportedValueDifferentPackage/foo/wire.go index a40390d..4f08716 100644 --- a/internal/wire/testdata/ExportedValueDifferentPackage/foo/wire.go +++ b/internal/wire/testdata/ExportedValueDifferentPackage/foo/wire.go @@ -19,7 +19,7 @@ package main import ( "os" - "bar" + "example.com/bar" "github.com/google/go-cloud/wire" ) diff --git a/internal/wire/testdata/ExportedValueDifferentPackage/pkg b/internal/wire/testdata/ExportedValueDifferentPackage/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/ExportedValueDifferentPackage/pkg +++ b/internal/wire/testdata/ExportedValueDifferentPackage/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/ImportedInterfaceBinding/bar/bar.go b/internal/wire/testdata/ImportedInterfaceBinding/bar/bar.go index f7cd1cf..7771f90 100644 --- a/internal/wire/testdata/ImportedInterfaceBinding/bar/bar.go +++ b/internal/wire/testdata/ImportedInterfaceBinding/bar/bar.go @@ -17,7 +17,7 @@ package main import ( "fmt" - "foo" + "example.com/foo" "github.com/google/go-cloud/wire" ) diff --git a/internal/wire/testdata/ImportedInterfaceBinding/bar/wire.go b/internal/wire/testdata/ImportedInterfaceBinding/bar/wire.go index 870d2ee..b813b54 100644 --- a/internal/wire/testdata/ImportedInterfaceBinding/bar/wire.go +++ b/internal/wire/testdata/ImportedInterfaceBinding/bar/wire.go @@ -17,7 +17,7 @@ package main import ( - "foo" + "example.com/foo" "github.com/google/go-cloud/wire" ) diff --git a/internal/wire/testdata/ImportedInterfaceBinding/pkg b/internal/wire/testdata/ImportedInterfaceBinding/pkg index 5716ca5..923cd07 100644 --- a/internal/wire/testdata/ImportedInterfaceBinding/pkg +++ b/internal/wire/testdata/ImportedInterfaceBinding/pkg @@ -1 +1 @@ -bar +example.com/bar diff --git a/internal/wire/testdata/ImportedInterfaceBinding/want/wire_gen.go b/internal/wire/testdata/ImportedInterfaceBinding/want/wire_gen.go index 1b369d9..02f1b22 100644 --- a/internal/wire/testdata/ImportedInterfaceBinding/want/wire_gen.go +++ b/internal/wire/testdata/ImportedInterfaceBinding/want/wire_gen.go @@ -6,7 +6,7 @@ package main import ( - foo "foo" + foo "example.com/foo" ) // Injectors from wire.go: diff --git a/internal/wire/testdata/InjectInput/pkg b/internal/wire/testdata/InjectInput/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/InjectInput/pkg +++ b/internal/wire/testdata/InjectInput/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/InjectInputConflict/pkg b/internal/wire/testdata/InjectInputConflict/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/InjectInputConflict/pkg +++ b/internal/wire/testdata/InjectInputConflict/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/InjectWithPanic/pkg b/internal/wire/testdata/InjectWithPanic/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/InjectWithPanic/pkg +++ b/internal/wire/testdata/InjectWithPanic/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/InterfaceBinding/pkg b/internal/wire/testdata/InterfaceBinding/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/InterfaceBinding/pkg +++ b/internal/wire/testdata/InterfaceBinding/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/InterfaceBindingReuse/pkg b/internal/wire/testdata/InterfaceBindingReuse/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/InterfaceBindingReuse/pkg +++ b/internal/wire/testdata/InterfaceBindingReuse/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/InterfaceValue/pkg b/internal/wire/testdata/InterfaceValue/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/InterfaceValue/pkg +++ b/internal/wire/testdata/InterfaceValue/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/InterfaceValueInvalidArg0/pkg b/internal/wire/testdata/InterfaceValueInvalidArg0/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/InterfaceValueInvalidArg0/pkg +++ b/internal/wire/testdata/InterfaceValueInvalidArg0/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/InterfaceValueNotEnoughArgs/pkg b/internal/wire/testdata/InterfaceValueNotEnoughArgs/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/InterfaceValueNotEnoughArgs/pkg +++ b/internal/wire/testdata/InterfaceValueNotEnoughArgs/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/MultipleMissingInputs/pkg b/internal/wire/testdata/MultipleMissingInputs/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/MultipleMissingInputs/pkg +++ b/internal/wire/testdata/MultipleMissingInputs/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/MultipleMissingInputs/want/wire_errs.txt b/internal/wire/testdata/MultipleMissingInputs/want/wire_errs.txt index 183f6f4..1d3dce6 100644 --- a/internal/wire/testdata/MultipleMissingInputs/want/wire_errs.txt +++ b/internal/wire/testdata/MultipleMissingInputs/want/wire_errs.txt @@ -1,2 +1,2 @@ -no provider found for foo.Foo -no provider found for foo.Bar +no provider found for example.com/foo.Foo +no provider found for example.com/foo.Bar diff --git a/internal/wire/testdata/NamingWorstCase/pkg b/internal/wire/testdata/NamingWorstCase/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/NamingWorstCase/pkg +++ b/internal/wire/testdata/NamingWorstCase/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/NamingWorstCaseAllInOne/pkg b/internal/wire/testdata/NamingWorstCaseAllInOne/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/NamingWorstCaseAllInOne/pkg +++ b/internal/wire/testdata/NamingWorstCaseAllInOne/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/NiladicIdentity/pkg b/internal/wire/testdata/NiladicIdentity/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/NiladicIdentity/pkg +++ b/internal/wire/testdata/NiladicIdentity/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/NiladicValue/pkg b/internal/wire/testdata/NiladicValue/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/NiladicValue/pkg +++ b/internal/wire/testdata/NiladicValue/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/NoImplicitInterface/pkg b/internal/wire/testdata/NoImplicitInterface/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/NoImplicitInterface/pkg +++ b/internal/wire/testdata/NoImplicitInterface/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/NoInjectParamNames/pkg b/internal/wire/testdata/NoInjectParamNames/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/NoInjectParamNames/pkg +++ b/internal/wire/testdata/NoInjectParamNames/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/NoopBuild/pkg b/internal/wire/testdata/NoopBuild/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/NoopBuild/pkg +++ b/internal/wire/testdata/NoopBuild/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/PartialCleanup/pkg b/internal/wire/testdata/PartialCleanup/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/PartialCleanup/pkg +++ b/internal/wire/testdata/PartialCleanup/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/PkgImport/foo/foo.go b/internal/wire/testdata/PkgImport/foo/foo.go index 2d755a8..228c574 100644 --- a/internal/wire/testdata/PkgImport/foo/foo.go +++ b/internal/wire/testdata/PkgImport/foo/foo.go @@ -17,7 +17,7 @@ package main import ( "fmt" - "bar" + "example.com/bar" "github.com/google/go-cloud/wire" ) diff --git a/internal/wire/testdata/PkgImport/pkg b/internal/wire/testdata/PkgImport/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/PkgImport/pkg +++ b/internal/wire/testdata/PkgImport/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/PkgImport/want/wire_gen.go b/internal/wire/testdata/PkgImport/want/wire_gen.go index 90c41c4..a4e44b0 100644 --- a/internal/wire/testdata/PkgImport/want/wire_gen.go +++ b/internal/wire/testdata/PkgImport/want/wire_gen.go @@ -6,7 +6,7 @@ package main import ( - bar "bar" + bar "example.com/bar" ) // Injectors from wire.go: diff --git a/internal/wire/testdata/ReturnError/pkg b/internal/wire/testdata/ReturnError/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/ReturnError/pkg +++ b/internal/wire/testdata/ReturnError/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/Struct/pkg b/internal/wire/testdata/Struct/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/Struct/pkg +++ b/internal/wire/testdata/Struct/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/StructPointer/pkg b/internal/wire/testdata/StructPointer/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/StructPointer/pkg +++ b/internal/wire/testdata/StructPointer/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/TwoDeps/pkg b/internal/wire/testdata/TwoDeps/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/TwoDeps/pkg +++ b/internal/wire/testdata/TwoDeps/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/UnexportedValue/foo/wire.go b/internal/wire/testdata/UnexportedValue/foo/wire.go index ea0bb83..e51f468 100644 --- a/internal/wire/testdata/UnexportedValue/foo/wire.go +++ b/internal/wire/testdata/UnexportedValue/foo/wire.go @@ -17,7 +17,7 @@ package main import ( - "bar" + "example.com/bar" "github.com/google/go-cloud/wire" ) diff --git a/internal/wire/testdata/UnexportedValue/pkg b/internal/wire/testdata/UnexportedValue/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/UnexportedValue/pkg +++ b/internal/wire/testdata/UnexportedValue/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/UnusedProviders/pkg b/internal/wire/testdata/UnusedProviders/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/UnusedProviders/pkg +++ b/internal/wire/testdata/UnusedProviders/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/UnusedProviders/want/wire_errs.txt b/internal/wire/testdata/UnusedProviders/want/wire_errs.txt index 13d8c09..d096736 100644 --- a/internal/wire/testdata/UnusedProviders/want/wire_errs.txt +++ b/internal/wire/testdata/UnusedProviders/want/wire_errs.txt @@ -1,4 +1,4 @@ unused provider set "unusedSet" unused provider "provideUnused" unused value of type string -unused interface binding to type foo.Fooer +unused interface binding to type example.com/foo.Fooer diff --git a/internal/wire/testdata/ValueChain/pkg b/internal/wire/testdata/ValueChain/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/ValueChain/pkg +++ b/internal/wire/testdata/ValueChain/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/ValueConversion/pkg b/internal/wire/testdata/ValueConversion/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/ValueConversion/pkg +++ b/internal/wire/testdata/ValueConversion/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/ValueIsInterfaceValue/pkg b/internal/wire/testdata/ValueIsInterfaceValue/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/ValueIsInterfaceValue/pkg +++ b/internal/wire/testdata/ValueIsInterfaceValue/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/VarValue/pkg b/internal/wire/testdata/VarValue/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/VarValue/pkg +++ b/internal/wire/testdata/VarValue/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/Vendor/foo/vendor/bar/bar.go b/internal/wire/testdata/Vendor/foo/vendor/example.com/bar/bar.go similarity index 100% rename from internal/wire/testdata/Vendor/foo/vendor/bar/bar.go rename to internal/wire/testdata/Vendor/foo/vendor/example.com/bar/bar.go diff --git a/internal/wire/testdata/Vendor/foo/wire.go b/internal/wire/testdata/Vendor/foo/wire.go index 68a1abb..b58e2f7 100644 --- a/internal/wire/testdata/Vendor/foo/wire.go +++ b/internal/wire/testdata/Vendor/foo/wire.go @@ -17,7 +17,7 @@ package main import ( - "bar" + "example.com/bar" "github.com/google/go-cloud/wire" ) diff --git a/internal/wire/testdata/Vendor/pkg b/internal/wire/testdata/Vendor/pkg index 257cc56..f7a5c8c 100644 --- a/internal/wire/testdata/Vendor/pkg +++ b/internal/wire/testdata/Vendor/pkg @@ -1 +1 @@ -foo +example.com/foo diff --git a/internal/wire/testdata/Vendor/want/wire_gen.go b/internal/wire/testdata/Vendor/want/wire_gen.go index adc0279..605d593 100644 --- a/internal/wire/testdata/Vendor/want/wire_gen.go +++ b/internal/wire/testdata/Vendor/want/wire_gen.go @@ -6,7 +6,7 @@ package main import ( - bar "bar" + bar "example.com/bar" ) // Injectors from wire.go: diff --git a/internal/wire/wire_test.go b/internal/wire/wire_test.go index 38a43e5..90ed012 100644 --- a/internal/wire/wire_test.go +++ b/internal/wire/wire_test.go @@ -71,6 +71,10 @@ func TestWire(t *testing.T) { for _, test := range tests { test := test t.Run(test.name, func(t *testing.T) { + if test.name == "Vendor" && os.Getenv("GO111MODULE") != "off" { + // TODO: Remove the GO111MODULE check when it is not relevant (maybe after Go 1.12). + t.Skip("Skipped testing for vendored package for Go module turned on, see https://github.com/google/go-cloud/issues/326") + } t.Parallel() // Run Wire from a fake build context. @@ -147,6 +151,9 @@ func goBuildCheck(test *testCase, wd string, bctx *build.Context, gen []byte) er return err } } + if err := writeGoMod(gopath); err != nil { + return err + } testExePath := filepath.Join(gopath, "bin", "testprog") realBuildCtx := &build.Context{ GOARCH: bctx.GOARCH, @@ -158,7 +165,8 @@ func goBuildCheck(test *testCase, wd string, bctx *build.Context, gen []byte) er BuildTags: bctx.BuildTags, ReleaseTags: bctx.ReleaseTags, } - if err := runGo(realBuildCtx, "build", "-o", testExePath, genPkg.ImportPath); err != nil { + buildDir := filepath.Join(gopath, "src", genPkg.ImportPath) + if err := runGo(realBuildCtx, buildDir, "build", "-o", testExePath); err != nil { return fmt.Errorf("build: %v", err) } @@ -342,7 +350,7 @@ func loadTestCase(root string, wireGoSrc []byte) (*testCase, error) { if !*setup.Record { wantWireOutput, err = ioutil.ReadFile(filepath.Join(root, "want", "wire_gen.go")) if err != nil { - return nil, fmt.Errorf("load test case %s: %v. If this is a new testcase, run with -record to generate the wire_gen.go file.", name, err) + return nil, fmt.Errorf("load test case %s: %v, if this is a new testcase, run with -record to generate the wire_gen.go file", name, err) } } wantProgramOutput, err = ioutil.ReadFile(filepath.Join(root, "want", "program_out.txt")) @@ -368,7 +376,7 @@ func loadTestCase(root string, wireGoSrc []byte) (*testCase, error) { if err != nil { return err } - goFiles[rel] = data + goFiles[filepath.Join("example.com", rel)] = data return nil }) if err != nil { @@ -576,10 +584,45 @@ func (test *testCase) materialize(gopath string) error { return nil } -func runGo(bctx *build.Context, args ...string) error { +// writeGoMod generates go.mod files for the test package and its dependency. +// The file structure looks like: +// +// gopath/src/ +// +// example.com/ +// +// go.mod +// replaces dependency with local copied one +// +// ... (Packages to be built and tested) +// any Go files copied recursively +// +// github.com/google/go-cloud/ +// +// go.mod +// +// ... (Dependency files copied) +func writeGoMod(gopath string) error { + importPath := "example.com" + depPath := "github.com/google/go-cloud" + depLoc := filepath.Join(gopath, "src", filepath.FromSlash(depPath)) + example := fmt.Sprintf("module %s\n\nreplace %s => %s\n", importPath, depPath, depLoc) + gomod := filepath.Join(gopath, "src", importPath, "go.mod") + if err := ioutil.WriteFile(gomod, []byte(example), 0666); err != nil { + return fmt.Errorf("generate go.mod for %s: %v", gomod, err) + } + if err := ioutil.WriteFile(filepath.Join(depLoc, "go.mod"), []byte("module "+depPath), 0666); err != nil { + return fmt.Errorf("generate go.mod for %s: %v", depPath, err) + } + return nil +} + +// runGo runs a go command in dir. +func runGo(bctx *build.Context, dir string, args ...string) error { exe := filepath.Join(bctx.GOROOT, "bin", "go") c := exec.Command(exe, args...) c.Env = append(os.Environ(), "GOROOT="+bctx.GOROOT, "GOARCH="+bctx.GOARCH, "GOOS="+bctx.GOOS, "GOPATH="+bctx.GOPATH) + c.Dir = dir if bctx.CgoEnabled { c.Env = append(c.Env, "CGO_ENABLED=1") } else {