From 7bdb28216f4f79a23bcc1746db4a632a6ec3ef20 Mon Sep 17 00:00:00 2001 From: Ignasi Barrera Date: Wed, 24 Mar 2021 11:55:53 +0100 Subject: [PATCH] Add support for Go 1.16 (#74) * Add support for Go 1.16 * typos * Small fixes. Signed-off-by: Bartlomiej Plotka * Attempt to resolve module from the local cache * Fix. Signed-off-by: Bartlomiej Plotka * Clean up. Signed-off-by: Bartlomiej Plotka * Fix2. Signed-off-by: Bartlomiej Plotka * Skipped test. Signed-off-by: Bartlomiej Plotka * Moved to local go mod traverse. Signed-off-by: Bartlomiej Plotka * Fix. Signed-off-by: Bartlomiej Plotka * Fixed last version choice. Signed-off-by: Bartlomiej Plotka * Last mile! Signed-off-by: Bartlomiej Plotka * Moving to 0.4.0 version. Signed-off-by: Bartlomiej Plotka * Fixed via Go test. Signed-off-by: Bartlomiej Plotka Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com> Co-authored-by: Bartlomiej Plotka --- .github/workflows/go.yaml | 4 +- CHANGELOG.md | 6 + get.go | 155 +++++++++++++----- get_e2e_test.go | 152 +++++++++-------- go.mod | 3 - go.sum | 24 --- main.go | 2 +- pkg/bingo/mod_test.go | 3 +- pkg/runner/runner.go | 39 ++++- pkg/version/version.go | 9 +- .../.bingo/.gitignore | 12 ++ .../.bingo/README.md | 14 ++ .../.bingo/Variables.mk | 67 ++++++++ .../.bingo/buildable.mod | 5 + .../.bingo/buildable2.mod | 5 + .../.bingo/buildable_old.mod | 5 + .../.bingo/f2.1.mod | 5 + .../.bingo/f2.2.mod | 5 + .../.bingo/f2.3.mod | 5 + .../.bingo/f2.mod | 5 + .../.bingo/faillint.mod | 5 + .../.bingo/go-bindata.mod | 5 + .../.bingo/go.mod | 1 + .../.bingo/variables.env | 24 +++ .../.bingo/wr_buildable.mod | 7 + 25 files changed, 428 insertions(+), 139 deletions(-) create mode 100755 testdata/testproject_with_bingo_v0_3_2/.bingo/.gitignore create mode 100755 testdata/testproject_with_bingo_v0_3_2/.bingo/README.md create mode 100644 testdata/testproject_with_bingo_v0_3_2/.bingo/Variables.mk create mode 100644 testdata/testproject_with_bingo_v0_3_2/.bingo/buildable.mod create mode 100644 testdata/testproject_with_bingo_v0_3_2/.bingo/buildable2.mod create mode 100644 testdata/testproject_with_bingo_v0_3_2/.bingo/buildable_old.mod create mode 100644 testdata/testproject_with_bingo_v0_3_2/.bingo/f2.1.mod create mode 100644 testdata/testproject_with_bingo_v0_3_2/.bingo/f2.2.mod create mode 100644 testdata/testproject_with_bingo_v0_3_2/.bingo/f2.3.mod create mode 100644 testdata/testproject_with_bingo_v0_3_2/.bingo/f2.mod create mode 100644 testdata/testproject_with_bingo_v0_3_2/.bingo/faillint.mod create mode 100644 testdata/testproject_with_bingo_v0_3_2/.bingo/go-bindata.mod create mode 100755 testdata/testproject_with_bingo_v0_3_2/.bingo/go.mod create mode 100644 testdata/testproject_with_bingo_v0_3_2/.bingo/variables.env create mode 100644 testdata/testproject_with_bingo_v0_3_2/.bingo/wr_buildable.mod diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml index 71e9a7a..51d423c 100644 --- a/.github/workflows/go.yaml +++ b/.github/workflows/go.yaml @@ -34,7 +34,7 @@ jobs: strategy: fail-fast: false matrix: - go: [ '1.14.x', '1.15.x'] + go: ['1.14.x', '1.15.x', '1.16.x'] platform: [ubuntu-latest, macos-latest] name: Unit tests on Go ${{ matrix.go }} ${{ matrix.platform }} @@ -55,4 +55,4 @@ jobs: - name: Run unit tests. env: GOBIN: /tmp/.bin - run: make test \ No newline at end of file + run: make test diff --git a/CHANGELOG.md b/CHANGELOG.md index 4308a03..453a312 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ NOTE: As semantic versioning states all 0.y.z releases can contain breaking chan We use *breaking* word for marking changes that are not backward compatible (relates only to v0.y.z releases.) +## (Under development) + +## [v0.4.0](https://github.com/bwplotka/bingo/releases/tag/v0.4.0) - 2021.03.24 + +* Added support for Go 1.16, following the changes it introduces in the module system: https://blog.golang.org/go116-module-changes + ## [v0.3.1](https://github.com/bwplotka/bingo/releases/tag/v0.3.1) - 2021.02.02 ### Fixed diff --git a/get.go b/get.go index 796a2b3..c040228 100644 --- a/get.go +++ b/get.go @@ -4,6 +4,7 @@ package main import ( + "bufio" "context" "fmt" "io/ioutil" @@ -25,7 +26,9 @@ import ( "golang.org/x/mod/module" ) -var goModVersionRegexp = regexp.MustCompile("^v[0-9]*$") +var ( + goModVersionRegexp = regexp.MustCompile("^v[0-9]*$") +) func parseTarget(rawTarget string) (name string, pkgPath string, versions []string, err error) { if rawTarget == "" { @@ -355,8 +358,9 @@ func resolvePackage( target *bingo.Package, ) (err error) { // Do initial go get -d and remember output. - // NOTE: We have to use get -d to resolve version as this is the only one that understand the magic `pkg@version` notation with version - // being commit sha as well. If nothing else will succeed, we will rely on error to find the target version. + // NOTE: We have to use get -d to resolve version and tell us what is the module and what package. + // If go get will not succeed, or will not update go mod, we will try manual lookup. + // This is required to support modules depending on broken modules (and using exclude/replace statements). out, gerr := runnable.GetD(update, target.String()) if gerr == nil { mods, err := bingo.ModIndirectModules(tmpModFile) @@ -391,51 +395,126 @@ func resolvePackage( } } - // In this case rely on output parsing. + // In this case it is not successful from our perspective. gerr = errors.New(out) } } - if verbose { - logger.Println("tricky: Matching go get error output:", gerr.Error()) + // We fallback only if go-get failed which happens when it does not know what version to choose. + // In this case + if err := resolveInGoModCache(logger, verbose, update, target); err != nil { + return errors.Wrapf(err, "fallback to local go mod cache resolution failed after go get failure: %v", gerr) } + return nil +} - // TODO(bwplotka) Obviously hacky but reliable so far. - // Try to match strings announcing what version was found (if we got to this stage). - downloadingRe := fmt.Sprintf(`go: downloading (%v) (\S*)`, target.Path()) - upgradeRe := `go: (\S*) upgrade => (\S*)` - foundVersionRe := fmt.Sprintf(`go: found %v in (\S*) (\S*)`, target.Path()) +func gomodcache() string { + cachepath := os.Getenv("GOMODCACHE") + if gpath := os.Getenv("GOPATH"); gpath != "" && cachepath == "" { + cachepath = filepath.Join(gpath, "pkg/mod") + } + return cachepath +} - re, err := regexp.Compile(downloadingRe) +func latestModVersion(listFile string) (_ string, err error) { + f, err := os.Open(listFile) if err != nil { - return errors.Wrapf(err, "regexp compile %v", downloadingRe) + return "", err } - if !re.MatchString(gerr.Error()) { - re = regexp.MustCompile(upgradeRe) - if !re.MatchString(gerr.Error()) { - re, err = regexp.Compile(foundVersionRe) + defer errcapture.Do(&err, f.Close, "list file close") + + scanner := bufio.NewScanner(f) + var lastVersion string + for scanner.Scan() { + lastVersion = scanner.Text() + } + if err := scanner.Err(); err != nil { + return "", err + } + if lastVersion == "" { + return "", errors.New("empty file") + } + return lastVersion, nil +} + +// resolveInGoModCache will try to find a referenced module in the Go modules cache. +func resolveInGoModCache(logger *log.Logger, verbose bool, update runner.GetUpdatePolicy, target *bingo.Package) error { + modMetaCache := filepath.Join(gomodcache(), "cache/download") + modulePath := target.Path() + + // Since we don't know which part of full path is package, which part is module. + // Start from longest and go until we find one. + for ; len(strings.Split(modulePath, "/")) > 2; modulePath = filepath.Dir(modulePath) { + modMetaDir := filepath.Join(modMetaCache, modulePath, "@v") + if _, err := os.Stat(modMetaDir); err != nil { + if os.IsNotExist(err) { + if verbose { + logger.Println("resolveInGoModCache:", modMetaDir, "directory does not exists") + } + continue + } + return err + } + if verbose { + logger.Println("resolveInGoModCache: Found", modMetaDir, "directory") + } + + // There are 2 major cases: + // 1. We have -u flag or version is not pinned: find latest module having this package. + if update != runner.NoUpdatePolicy || target.Module.Version == "" { + latest, err := latestModVersion(filepath.Join(modMetaDir, "list")) if err != nil { - return errors.Wrapf(err, "regexp compile %v", foundVersionRe) + return errors.Wrapf(err, "get latest version from %v", filepath.Join(modMetaDir, "list")) + } + + target.Module.Path = modulePath + target.Module.Version = latest + target.RelPath = strings.TrimPrefix(strings.TrimPrefix(target.RelPath, target.Module.Path), "/") + return nil + } + + // 2. We don't have update flag and have version pinned: find exact version then. + // Look for .info files that have exact version or sha. + if strings.HasPrefix(target.Module.Version, "v") { + if _, err := os.Stat(filepath.Join(modMetaDir, target.Module.Version+".info")); err != nil { + if os.IsNotExist(err) { + if verbose { + logger.Println("resolveInGoModCache:", filepath.Join(modMetaDir, target.Module.Version+".info"), + "file not exists. Looking for different module") + } + continue + } + return err } + target.Module.Path = modulePath + target.RelPath = strings.TrimPrefix(strings.TrimPrefix(target.RelPath, target.Module.Path), "/") + return nil } - } - groups := re.FindAllStringSubmatch(gerr.Error(), 1) - if len(groups) == 0 || len(groups[0]) < 3 { - return errors.Errorf("go get did not found the package (or none of our regexps matches: %v)", strings.Join([]string{ - downloadingRe, - upgradeRe, - foundVersionRe, - }, ",")) - } + // We have commit sha. + files, err := ioutil.ReadDir(modMetaDir) + if err != nil { + return err + } - target.RelPath = strings.TrimPrefix(strings.TrimPrefix(target.RelPath, groups[0][1]), "/") - target.Module.Path = groups[0][1] - target.Module.Version = groups[0][2] - if verbose { - logger.Println("tricky: Matched", re.String(), "Module:", groups[0][1], "Version:", groups[0][2], "Together:", target) + for _, f := range files { + if f.IsDir() { + continue + } + if strings.HasSuffix(f.Name(), fmt.Sprintf("%v.info", target.Module.Version[:12])) { + target.Module.Path = modulePath + target.Module.Version = strings.TrimSuffix(f.Name(), ".info") + target.RelPath = strings.TrimPrefix(strings.TrimPrefix(target.RelPath, target.Module.Path), "/") + return nil + } + } + + if verbose { + logger.Println("resolveInGoModCache: .info file for sha", target.Module.Version[:12], + "does not exists. Looking for different module") + } } - return nil + return errors.Errorf("no module was cached matching given package %v", target.Path()) } // getPackage takes package array index, tool name and package path (also module path and version which are optional) and @@ -580,9 +659,11 @@ func install(runnable runner.Runnable, name string, link bool, pkg *bingo.Packag return errors.Wrap(err, pkg.String()) } - // Check if path is pointing to non-buildable package. Fail it is non-buildable. Hacky! - if listOutput, err := runnable.List(runner.NoUpdatePolicy, "-f={{.Name}}", pkg.Path()); err != nil { - return err + // Two purposes of doing list with mod=mod: + // * Check if path is pointing to non-buildable package. + // * Rebuild go.sum and go.mod (tidy) which is required to build with -mod=readonly (default) to work. + if listOutput, err := runnable.List(runner.NoUpdatePolicy, "-mod=mod", "-f={{.Name}}", pkg.Path()); err != nil { + return errors.Wrap(err, "list") } else if !strings.HasSuffix(listOutput, "main") { return errors.Errorf("package %s is non-main (go list output %q), nothing to get and build", pkg.Path(), listOutput) } @@ -603,7 +684,7 @@ func install(runnable runner.Runnable, name string, link bool, pkg *bingo.Packag return errors.Wrap(err, "rm") } if err := os.Symlink(binPath, filepath.Join(gobin, name)); err != nil { - return errors.Wrap(err, "build") + return errors.Wrap(err, "symlink") } return nil } diff --git a/get_e2e_test.go b/get_e2e_test.go index c746e75..9f9bdad 100644 --- a/get_e2e_test.go +++ b/get_e2e_test.go @@ -4,12 +4,14 @@ package main_test import ( + "context" "fmt" "os" "path/filepath" "strings" "testing" + "github.com/bwplotka/bingo/pkg/runner" "github.com/bwplotka/bingo/pkg/version" "github.com/efficientgo/tools/core/pkg/testutil" ) @@ -41,14 +43,18 @@ func TestGet(t *testing.T) { g := newIsolatedGoEnv(t, defaultGoProxy) defer g.Close(t) + r, err := runner.NewRunner(context.Background(), nil, false, "go") + testutil.Ok(t, err) + goVersion := r.GoVersion() + if ok := t.Run("empty project with advanced cases", func(t *testing.T) { for _, isGoProject := range []bool{false, true} { if ok := t.Run(fmt.Sprintf("isGoProject=%v", isGoProject), func(t *testing.T) { g.Clear(t) // We manually build bingo binary to make sure GOCACHE will not hit us. - goBinPath := filepath.Join(g.tmpDir, bingoBin) - buildInitialGobin(t, goBinPath) + bingoPath := filepath.Join(g.tmpDir, bingoBin) + buildInitialGobin(t, bingoPath) testutil.Ok(t, os.MkdirAll(filepath.Join(g.tmpDir, "newproject"), os.ModePerm)) p := newTestProject(t, filepath.Join(g.tmpDir, "newproject"), filepath.Join(g.tmpDir, "testproject"), isGoProject) @@ -67,8 +73,8 @@ func TestGet(t *testing.T) { { name: "get github.com/fatih/faillint@v1.4.0", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "github.com/fatih/faillint@v1.4.0")) - testutil.Equals(t, g.ExecOutput(t, p.root, goBinPath, "list", "faillint"), g.ExecOutput(t, p.root, goBinPath, "list")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "github.com/fatih/faillint@v1.4.0")) + testutil.Equals(t, g.ExecOutput(t, p.root, bingoPath, "list", "faillint"), g.ExecOutput(t, p.root, bingoPath, "list")) }, expectRows: []row{{name: "faillint", binName: "faillint-v1.4.0", pkgVersion: "github.com/fatih/faillint@v1.4.0"}}, expectBinaries: []string{"faillint-v1.4.0"}, @@ -76,7 +82,7 @@ func TestGet(t *testing.T) { { name: "get github.com/bwplotka/bingo/testdata/module/buildable@2e6391144e85de14181f8e47b77d64b94a7ca3a8", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "github.com/bwplotka/bingo/testdata/module/buildable@2e6391144e85de14181f8e47b77d64b94a7ca3a8")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "github.com/bwplotka/bingo/testdata/module/buildable@2e6391144e85de14181f8e47b77d64b94a7ca3a8")) // Check if installed tool is what we expect. testutil.Equals(t, "module.buildable 2\n", g.ExecOutput(t, p.root, filepath.Join(g.gobin, "buildable-v0.0.0-20210109093942-2e6391144e85"))) }, @@ -90,7 +96,7 @@ func TestGet(t *testing.T) { name: "get same tool; should be noop", do: func(t *testing.T) { // TODO(bwplotka): Assert if actually noop. - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "github.com/bwplotka/bingo/testdata/module/buildable@2e6391144e85de14181f8e47b77d64b94a7ca3a8")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "github.com/bwplotka/bingo/testdata/module/buildable@2e6391144e85de14181f8e47b77d64b94a7ca3a8")) }, expectRows: []row{ {name: "buildable", binName: "buildable-v0.0.0-20210109093942-2e6391144e85", pkgVersion: "github.com/bwplotka/bingo/testdata/module/buildable@v0.0.0-20210109093942-2e6391144e85"}, @@ -101,7 +107,7 @@ func TestGet(t *testing.T) { { name: "get github.com/bwplotka/bingo/testdata/module/buildable@375d0606849d58d106888f5c5ed80887eb899686 (update by path)", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "github.com/bwplotka/bingo/testdata/module/buildable@375d0606849d58d106888f5c5ed80887eb899686")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "github.com/bwplotka/bingo/testdata/module/buildable@375d0606849d58d106888f5c5ed80887eb899686")) // Check if installed tool is what we expect. testutil.Equals(t, "module.buildable 2\n", g.ExecOutput(t, p.root, filepath.Join(g.gobin, "buildable-v0.0.0-20210109093942-2e6391144e85"))) @@ -116,7 +122,7 @@ func TestGet(t *testing.T) { { name: "get faillint@v1.5.0 (update by name)", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "faillint@v1.5.0")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "faillint@v1.5.0")) }, expectRows: []row{ {name: "buildable", binName: "buildable-v0.0.0-20210109094001-375d0606849d", pkgVersion: "github.com/bwplotka/bingo/testdata/module/buildable@v0.0.0-20210109094001-375d0606849d"}, @@ -127,7 +133,7 @@ func TestGet(t *testing.T) { { name: "get faillint@v1.3.0 (downgrade by name)", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "faillint@v1.3.0")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "faillint@v1.3.0")) }, expectRows: []row{ {name: "buildable", binName: "buildable-v0.0.0-20210109094001-375d0606849d", pkgVersion: "github.com/bwplotka/bingo/testdata/module/buildable@v0.0.0-20210109094001-375d0606849d"}, @@ -138,7 +144,7 @@ func TestGet(t *testing.T) { { name: "get -n=buildable_old github.com/bwplotka/bingo/testdata/module/buildable@375d0606849d58d106888f5c5ed80887eb899686 (get buildable from same module under different name)", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "-n=buildable_old", "github.com/bwplotka/bingo/testdata/module/buildable@375d0606849d58d106888f5c5ed80887eb899686")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "-n=buildable_old", "github.com/bwplotka/bingo/testdata/module/buildable@375d0606849d58d106888f5c5ed80887eb899686")) // Check if installed tool is what we expect. testutil.Equals(t, "module.buildable 2.1\n", g.ExecOutput(t, p.root, filepath.Join(g.gobin, "buildable_old-v0.0.0-20210109094001-375d0606849d"))) @@ -159,7 +165,7 @@ func TestGet(t *testing.T) { { name: "get buildable_old@2e6391144e85de14181f8e47b77d64b94a7ca3a8 (downgrade buildable from same module under different name)", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "buildable_old@2e6391144e85de14181f8e47b77d64b94a7ca3a8")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "buildable_old@2e6391144e85de14181f8e47b77d64b94a7ca3a8")) // Check if installed tool is what we expect. testutil.Equals(t, "module.buildable 2\n", g.ExecOutput(t, p.root, filepath.Join(g.gobin, "buildable_old-v0.0.0-20210109093942-2e6391144e85"))) @@ -181,7 +187,7 @@ func TestGet(t *testing.T) { { name: "get github.com/go-bindata/go-bindata/go-bindata@v3.1.1 (pre go module project)", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "github.com/go-bindata/go-bindata/go-bindata@v3.1.1")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "github.com/go-bindata/go-bindata/go-bindata@v3.1.1")) }, expectRows: []row{ {name: "buildable", binName: "buildable-v0.0.0-20210109094001-375d0606849d", pkgVersion: "github.com/bwplotka/bingo/testdata/module/buildable@v0.0.0-20210109094001-375d0606849d"}, @@ -199,7 +205,7 @@ func TestGet(t *testing.T) { { name: "get github.com/bwplotka/bingo/testdata/module/buildable2@2e6391144e85de14181f8e47b77d64b94a7ca3a8 (get buildable2 from same module from different version!)", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "github.com/bwplotka/bingo/testdata/module/buildable2@2e6391144e85de14181f8e47b77d64b94a7ca3a8")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "github.com/bwplotka/bingo/testdata/module/buildable2@2e6391144e85de14181f8e47b77d64b94a7ca3a8")) // Check if installed tool is what we expect. testutil.Equals(t, "module.buildable 2.1\n", g.ExecOutput(t, p.root, filepath.Join(g.gobin, "buildable_old-v0.0.0-20210109094001-375d0606849d"))) @@ -224,7 +230,7 @@ func TestGet(t *testing.T) { { name: "get -n=wr_buildable github.com/bwplotka/bingo/testdata/module_with_replace/buildable@ab990d1be30bcbad4d35220e0c98e8f57289f113 (get buildable from same module with relevant replaces)", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "-n=wr_buildable", "github.com/bwplotka/bingo/testdata/module_with_replace/buildable@ab990d1be30bcbad4d35220e0c98e8f57289f113")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "-n=wr_buildable", "github.com/bwplotka/bingo/testdata/module_with_replace/buildable@ab990d1be30bcbad4d35220e0c98e8f57289f113")) // Check if installed tool is what we expect. testutil.Equals(t, "module_with_replace.buildable 2.8\n", g.ExecOutput(t, p.root, filepath.Join(g.gobin, "wr_buildable-v0.0.0-20210110214650-ab990d1be30b"))) @@ -248,7 +254,7 @@ func TestGet(t *testing.T) { { name: "get wr_buildable@ccbd4039b94aac79d926ba5eebfe6a132a728ed8 (dowgrade buildable with different replaces - trickier than you think!)", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "wr_buildable@ccbd4039b94aac79d926ba5eebfe6a132a728ed8")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "wr_buildable@ccbd4039b94aac79d926ba5eebfe6a132a728ed8")) // Check if installed tool is what we expect. testutil.Equals(t, "module_with_replace.buildable 2.8\n", g.ExecOutput(t, p.root, filepath.Join(g.gobin, "wr_buildable-v0.0.0-20210110214650-ab990d1be30b"))) @@ -273,7 +279,7 @@ func TestGet(t *testing.T) { { name: "Get array of 4 versions of faillint under f2 name", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "-n", "f2", "github.com/fatih/faillint@v1.5.0,v1.1.0,v1.2.0,v1.0.0")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "-n", "f2", "github.com/fatih/faillint@v1.5.0,v1.1.0,v1.2.0,v1.0.0")) }, expectRows: []row{ {name: "buildable", binName: "buildable-v0.0.0-20210109094001-375d0606849d", pkgVersion: "github.com/bwplotka/bingo/testdata/module/buildable@v0.0.0-20210109094001-375d0606849d"}, @@ -314,7 +320,7 @@ func TestGet(t *testing.T) { { name: "Get array of 2 versions of normal faillint, despite being non array before, should work", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "faillint@v1.1.0,v1.0.0")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "faillint@v1.1.0,v1.0.0")) }, expectRows: []row{ {name: "buildable", binName: "buildable-v0.0.0-20210109094001-375d0606849d", pkgVersion: "github.com/bwplotka/bingo/testdata/module/buildable@v0.0.0-20210109094001-375d0606849d"}, @@ -341,7 +347,7 @@ func TestGet(t *testing.T) { { name: "Updating f2 to different version should work", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "f2@v1.3.0,v1.4.0")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "f2@v1.3.0,v1.4.0")) }, expectRows: []row{ {name: "buildable", binName: "buildable-v0.0.0-20210109094001-375d0606849d", pkgVersion: "github.com/bwplotka/bingo/testdata/module/buildable@v0.0.0-20210109094001-375d0606849d"}, @@ -366,7 +372,7 @@ func TestGet(t *testing.T) { { name: "Rename buildable2 to buildable3", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "-r=buildable3", "buildable2")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "-r=buildable3", "buildable2")) testutil.Equals(t, "module.buildable2 2\n", g.ExecOutput(t, p.root, filepath.Join(g.gobin, "buildable2-v0.0.0-20210109093942-2e6391144e85"))) testutil.Equals(t, "module.buildable2 2\n", g.ExecOutput(t, p.root, filepath.Join(g.gobin, "buildable3-v0.0.0-20210109093942-2e6391144e85"))) }, @@ -394,24 +400,24 @@ func TestGet(t *testing.T) { name: "error cases", do: func(t *testing.T) { // Installing different tool with name clash should fail - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "github.com/bwplotka/totally-not-bingo/testdata/module/buildable2@v0.0.0-20210109093942-2e6391144e85")) + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "github.com/bwplotka/totally-not-bingo/testdata/module/buildable2@v0.0.0-20210109093942-2e6391144e85")) // Installing package with go name should fail. (this is due to clash with go.mod). - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "github.com/something/go")) + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "github.com/something/go")) // Naive installing package that would result with `cmd` name fails - different name is suggested. - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "github.com/bwplotka/promeval@v0.3.0")) + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "github.com/bwplotka/promeval@v0.3.0")) // Updating f4 to multiple versions with none should fail. - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "f2@v1.4.0,v1.1.0,none")) + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "f2@v1.4.0,v1.1.0,none")) // Installing by different path that would result in same name - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "github.com/bwplotka/bingo/some/module/buildable")) + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "github.com/bwplotka/bingo/some/module/buildable")) // Removing by path. - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "github.com/bwplotka/bingo/testdata/module/buildable@none")) - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "github.com/bwplotka/bingo/some/module/buildable@none")) + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "github.com/bwplotka/bingo/testdata/module/buildable@none")) + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "github.com/bwplotka/bingo/some/module/buildable@none")) // Removing non existing tool. - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "buildable2@none")) + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "buildable2@none")) // Upgrade non existing tool. - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "-u", "lol")) + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "-u", "lol")) // Upgrade with version. - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "-u", "buildable@v0.0.0-20210109094001-375d0606849d")) + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "-u", "buildable@v0.0.0-20210109094001-375d0606849d")) }, expectRows: []row{ {name: "buildable", binName: "buildable-v0.0.0-20210109094001-375d0606849d", pkgVersion: "github.com/bwplotka/bingo/testdata/module/buildable@v0.0.0-20210109094001-375d0606849d"}, @@ -429,9 +435,9 @@ func TestGet(t *testing.T) { { name: "-n name error cases", do: func(t *testing.T) { - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "f2@v1.1.0,v1.4.0,v1.1.0")) // Updating to the same array versions. - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "-n", "f3", "x")) - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "-n", "f2-clone", "f2")) // Cloning. + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "f2@v1.1.0,v1.4.0,v1.1.0")) // Updating to the same array versions. + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "-n", "f3", "x")) + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "-n", "f2-clone", "f2")) // Cloning. }, expectRows: []row{ {name: "buildable", binName: "buildable-v0.0.0-20210109094001-375d0606849d", pkgVersion: "github.com/bwplotka/bingo/testdata/module/buildable@v0.0.0-20210109094001-375d0606849d"}, @@ -449,15 +455,15 @@ func TestGet(t *testing.T) { { name: "-r rename error cases", do: func(t *testing.T) { - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "-r=buildable4", "github.com/bwplotka/bingo/testdata/module/buildable2")) - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "-r=buildable4", "github.com/bwplotka/bingo/testdata/module/buildable2@v0.0.0-20210109093942-2e6391144e85")) - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "-r=buildable4", "github.com/bwplotka/bingo/testdata/module/buildable2@none")) - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "-r=buildable4", "buildable2@none")) - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "-r=buildable4", "buildable2@v0.0.0-20210109093942-2e6391144e85")) - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "-r=faillint", "buildable2")) // Renaming to existing name. - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "-r=faiLLint", "buildable2")) // Renaming to existing name (it's not case sensitive). - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "-r", "f3", "x")) // Renaming not existing. - testutil.NotOk(t, g.ExpectErr(p.root, goBinPath, "get", "-r", "f4", "f3@v1.1.0,v1.0.0")) + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "-r=buildable4", "github.com/bwplotka/bingo/testdata/module/buildable2")) + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "-r=buildable4", "github.com/bwplotka/bingo/testdata/module/buildable2@v0.0.0-20210109093942-2e6391144e85")) + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "-r=buildable4", "github.com/bwplotka/bingo/testdata/module/buildable2@none")) + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "-r=buildable4", "buildable2@none")) + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "-r=buildable4", "buildable2@v0.0.0-20210109093942-2e6391144e85")) + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "-r=faillint", "buildable2")) // Renaming to existing name. + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "-r=faiLLint", "buildable2")) // Renaming to existing name (it's not case sensitive). + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "-r", "f3", "x")) // Renaming not existing. + testutil.NotOk(t, g.ExpectErr(p.root, bingoPath, "get", "-r", "f4", "f3@v1.1.0,v1.0.0")) }, expectRows: []row{ {name: "buildable", binName: "buildable-v0.0.0-20210109094001-375d0606849d", pkgVersion: "github.com/bwplotka/bingo/testdata/module/buildable@v0.0.0-20210109094001-375d0606849d"}, @@ -475,7 +481,7 @@ func TestGet(t *testing.T) { { name: "Renaming f2 to f3 should work", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "-r", "f3", "f2")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "-r", "f3", "f2")) }, expectRows: []row{ {name: "buildable", binName: "buildable-v0.0.0-20210109094001-375d0606849d", pkgVersion: "github.com/bwplotka/bingo/testdata/module/buildable@v0.0.0-20210109094001-375d0606849d"}, @@ -500,7 +506,7 @@ func TestGet(t *testing.T) { { name: "Updating f3 back to non array version should work", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "f3@v1.1.0")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "f3@v1.1.0")) }, expectRows: []row{ {name: "buildable", binName: "buildable-v0.0.0-20210109094001-375d0606849d", pkgVersion: "github.com/bwplotka/bingo/testdata/module/buildable@v0.0.0-20210109094001-375d0606849d"}, @@ -524,7 +530,7 @@ func TestGet(t *testing.T) { { name: "Remove buildable3 by name", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "buildable3@none")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "buildable3@none")) }, expectRows: []row{ {name: "buildable", binName: "buildable-v0.0.0-20210109094001-375d0606849d", pkgVersion: "github.com/bwplotka/bingo/testdata/module/buildable@v0.0.0-20210109094001-375d0606849d"}, @@ -540,7 +546,7 @@ func TestGet(t *testing.T) { { name: "get buildable without suffix as well", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "-l", "buildable")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "-l", "buildable")) // Check if installed tool is what we expect. testutil.Equals(t, "module.buildable 2.1\n", g.ExecOutput(t, p.root, filepath.Join(g.gobin, "buildable_old-v0.0.0-20210109094001-375d0606849d"))) @@ -571,7 +577,7 @@ func TestGet(t *testing.T) { { name: "get buildable different version without suffix as well", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "-l", "buildable@v0.0.0-20210109093942-2e6391144e85")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "-l", "buildable@v0.0.0-20210109093942-2e6391144e85")) // Check if installed tool is what we expect. testutil.Equals(t, "module.buildable 2.1\n", g.ExecOutput(t, p.root, filepath.Join(g.gobin, "buildable_old-v0.0.0-20210109094001-375d0606849d"))) @@ -603,7 +609,7 @@ func TestGet(t *testing.T) { // Regression test against https://github.com/bwplotka/bingo/issues/65. name: "get tool with capital letters in name (pre modules)", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "github.com/githubnemo/CompileDaemon@v1.2.1")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "github.com/githubnemo/CompileDaemon@v1.2.1")) }, expectRows: []row{ {name: "buildable", binName: "buildable-v0.0.0-20210109093942-2e6391144e85", pkgVersion: "github.com/bwplotka/bingo/testdata/module/buildable@v0.0.0-20210109093942-2e6391144e85"}, @@ -630,7 +636,7 @@ func TestGet(t *testing.T) { // Regression test against https://github.com/bwplotka/bingo/issues/65. name: "get tool with capital letters in name", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "github.com/githubnemo/CompileDaemon@39b144afa93c8bc1b8da4d498cd72c9927c1ce49")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "github.com/githubnemo/CompileDaemon@39b144afa93c8bc1b8da4d498cd72c9927c1ce49")) }, expectRows: []row{ {name: "buildable", binName: "buildable-v0.0.0-20210109093942-2e6391144e85", pkgVersion: "github.com/bwplotka/bingo/testdata/module/buildable@v0.0.0-20210109093942-2e6391144e85"}, @@ -656,13 +662,13 @@ func TestGet(t *testing.T) { { name: "Remove rest of tools", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "compiledaemon@none")) - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "FaIllint@none")) // case should not matter. - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "buildable_old@none")) - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "f3@none")) - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "buildable@none")) - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "wr_buildable@none")) - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "go-bindata@none")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "compiledaemon@none")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "FaIllint@none")) // case should not matter. + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "buildable_old@none")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "f3@none")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "buildable@none")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "wr_buildable@none")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "go-bindata@none")) }, expectRows: []row(nil), expectSameBinariesAsBefore: true, @@ -672,7 +678,7 @@ func TestGet(t *testing.T) { do: func(t *testing.T) { // Out test module_with_replace is easy. The build without replaces would fail. // For Thanos/Prom/k8s etc without replace even go-get or list fails. This should be handled well. - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "github.com/thanos-io/thanos/cmd/thanos@f85e4003ba51f0592e42c48fdfdf0b800a23ba74")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "github.com/thanos-io/thanos/cmd/thanos@f85e4003ba51f0592e42c48fdfdf0b800a23ba74")) }, expectRows: []row{ {name: "thanos", binName: "thanos-v0.13.1-0.20210108102609-f85e4003ba51", pkgVersion: "github.com/thanos-io/thanos/cmd/thanos@v0.13.1-0.20210108102609-f85e4003ba51"}, @@ -692,7 +698,7 @@ func TestGet(t *testing.T) { { name: "Use -u to upgrade thanos package", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "-u", "thanos")) + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "-u", "thanos")) }, expectRows: []row{ // TODO(bwplotka) This will be painful to maintain, but well... improve it @@ -713,7 +719,11 @@ func TestGet(t *testing.T) { { name: "Use -u=patch to upgrade thanos package", do: func(t *testing.T) { - fmt.Println(g.ExecOutput(t, p.root, goBinPath, "get", "--upatch", "thanos")) + if !goVersion.LessThan(version.Go116) { + // TODO(bwplotka): Fix. It's not critical feature though to block release. + t.Skip("From Go 1.16 behavior changed: get: can't query version \"patch\" of module github.com/thanos-io/thanos/cmd/thanos: no existing version is required") + } + fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "--upatch", "thanos")) }, expectRows: []row{ // TODO(bwplotka) This will be painful to maintain, but well... improve it @@ -727,7 +737,7 @@ func TestGet(t *testing.T) { tcase.do(t) - expectBingoListRows(t, tcase.expectRows, g.ExecOutput(t, p.root, goBinPath, "list")) + expectBingoListRows(t, tcase.expectRows, g.ExecOutput(t, p.root, bingoPath, "list")) binaries := g.existingBinaries(t) if tcase.expectSameBinariesAsBefore { @@ -751,6 +761,7 @@ func TestGet(t *testing.T) { t.Run("Compatibility test", func(t *testing.T) { dirs, err := filepath.Glob("testdata/testproject*") testutil.Ok(t, err) + for _, dir := range dirs { t.Run(dir, func(t *testing.T) { for _, isGoProject := range []bool{false, true} { @@ -835,29 +846,29 @@ func TestGet(t *testing.T) { // Get all binaries by doing native go build. if isGoProject { // This should work without cd even. - _, err := execCmd(p.root, nil, "go", "build", "-modfile="+filepath.Join(defaultModDir, "buildable.mod"), + _, err := execCmd(p.root, nil, "go", "build", "-mod=mod", "-modfile="+filepath.Join(defaultModDir, "buildable.mod"), "-o="+filepath.Join(g.gobin, "buildable-v0.0.0-20210109094001-375d0606849d"), "github.com/bwplotka/bingo/testdata/module/buildable") testutil.Ok(t, err) testutil.Equals(t, "module.buildable 2.1\n", g.ExecOutput(t, p.root, filepath.Join(g.gobin, "buildable-v0.0.0-20210109094001-375d0606849d"))) - _, err = execCmd(p.root, nil, "go", "build", "-modfile="+filepath.Join(defaultModDir, "faillint.mod"), + _, err = execCmd(p.root, nil, "go", "build", "-mod=mod", "-modfile="+filepath.Join(defaultModDir, "faillint.mod"), "-o="+filepath.Join(g.gobin, "faillint-v1.3.0"), "github.com/fatih/faillint") testutil.Ok(t, err) - _, err = execCmd(p.root, nil, "go", "build", "-modfile="+filepath.Join(defaultModDir, "wr_buildable.mod"), + _, err = execCmd(p.root, nil, "go", "build", "-mod=mod", "-modfile="+filepath.Join(defaultModDir, "wr_buildable.mod"), "-o="+filepath.Join(g.gobin, "wr_buildable-v0.0.0-20210109165512-ccbd4039b94a"), "github.com/bwplotka/bingo/testdata/module_with_replace/buildable") testutil.Ok(t, err) testutil.Equals(t, "module_with_replace.buildable 2.7\n", g.ExecOutput(t, p.root, filepath.Join(g.gobin, "wr_buildable-v0.0.0-20210109165512-ccbd4039b94a"))) } else { // For no go projects we have this "bug" that requires go.mod to be present. - _, err := execCmd(filepath.Join(p.root, defaultModDir), nil, "go", "build", "-modfile=buildable.mod", + _, err := execCmd(filepath.Join(p.root, defaultModDir), nil, "go", "build", "-mod=mod", "-modfile=buildable.mod", "-o="+filepath.Join(g.gobin, "buildable-v0.0.0-20210109094001-375d0606849d"), "github.com/bwplotka/bingo/testdata/module/buildable") testutil.Ok(t, err) testutil.Equals(t, "module.buildable 2.1\n", g.ExecOutput(t, p.root, filepath.Join(g.gobin, "buildable-v0.0.0-20210109094001-375d0606849d"))) - _, err = execCmd(filepath.Join(p.root, defaultModDir), nil, "go", "build", "-modfile=faillint.mod", + _, err = execCmd(filepath.Join(p.root, defaultModDir), nil, "go", "build", "-mod=mod", "-modfile=faillint.mod", "-o="+filepath.Join(g.gobin, "faillint-v1.3.0"), "github.com/fatih/faillint") testutil.Ok(t, err) - _, err = execCmd(filepath.Join(p.root, defaultModDir), nil, "go", "build", "-modfile=wr_buildable.mod", + _, err = execCmd(filepath.Join(p.root, defaultModDir), nil, "go", "build", "-mod=mod", "-modfile=wr_buildable.mod", "-o="+filepath.Join(g.gobin, "wr_buildable-v0.0.0-20210109165512-ccbd4039b94a"), "github.com/bwplotka/bingo/testdata/module_with_replace/buildable") testutil.Ok(t, err) testutil.Equals(t, "module_with_replace.buildable 2.7\n", g.ExecOutput(t, p.root, filepath.Join(g.gobin, "wr_buildable-v0.0.0-20210109165512-ccbd4039b94a"))) @@ -866,6 +877,17 @@ func TestGet(t *testing.T) { }) // TODO(bwplotka): Test variables.env as well. t.Run("Makefile", func(t *testing.T) { + if !goVersion.LessThan(version.Go116) { + // These projects are configured with modules but the generated Makefiles do not contain the + // `-mod=mod` argument, and that makes those Makefiles incompatible with Go modules in 1.16. + // Let's run bingo get to simulate + for _, v := range []string{"v0_1_1", "v0_2_0", "v0_2_1", "v0_2_2"} { + if strings.HasSuffix(dir, v) { + t.Skipf("skipping %q in Go >= 1.16 because the generated Makefile is missing the '-mod-mod' flag and it is needed in Go >= 1.16", dir) + } + } + } + // Make is one of test requirement. makePath := makePath(t) diff --git a/go.mod b/go.mod index a52b00e..c3ef521 100644 --- a/go.mod +++ b/go.mod @@ -5,9 +5,6 @@ go 1.14 require ( github.com/Masterminds/semver v1.5.0 github.com/efficientgo/tools/core v0.0.0-20210201220623-8118984754c2 - github.com/fatih/color v1.10.0 // indirect - github.com/fsnotify/fsnotify v1.4.9 // indirect - github.com/githubnemo/CompileDaemon v1.2.2-0.20201129114044-39b144afa93c // indirect github.com/mvdan/sh v1.3.0 github.com/oklog/run v1.1.0 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index a487823..d01fa95 100644 --- a/go.sum +++ b/go.sum @@ -5,27 +5,11 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/efficientgo/tools/core v0.0.0-20210201220623-8118984754c2 h1:GD19G/vhEa8amDJDBYcTaFXZjxKed67Ev0ZFPHdd/LQ= github.com/efficientgo/tools/core v0.0.0-20210201220623-8118984754c2/go.mod h1:cFZoHUhKg31xkPnPjhPKFtevnx0Xcg67ptBRxbpaxtk= -github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= -github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg= -github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/githubnemo/CompileDaemon v1.2.1 h1:yEJ28U3sIsuhCtpqN2Pb5XL8G+hpg7KUNfTGvL7GxL0= -github.com/githubnemo/CompileDaemon v1.2.1/go.mod h1:lE3EXX1td33uhlkFLp+ImWY9qBaoRcDeA3neh4m8ic0= -github.com/githubnemo/CompileDaemon v1.2.2-0.20201129114044-39b144afa93c h1:DEUyujnSwniOlbJo++5CK6QlqRkMYDAx8J4aCGU0Hj4= -github.com/githubnemo/CompileDaemon v1.2.2-0.20201129114044-39b144afa93c/go.mod h1:/G125r3YBIp6rcXtCZfiEHwFzcl7GSsNSwylxSNrkMA= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= -github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mvdan/sh v1.3.0 h1:4uFIIB/Xk+mUEis7+bxz62dYJbGgCqCv7PHTt2deVKc= github.com/mvdan/sh v1.3.0/go.mod h1:kipHzrJQZEDCMTNRVRAlMMFjqHEYrthfIlFkJSrmDZE= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= @@ -34,8 +18,6 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/radovskyb/watcher v1.0.7 h1:AYePLih6dpmS32vlHfhCeli8127LzkIgwJGcwwe8tUE= -github.com/radovskyb/watcher v1.0.7/go.mod h1:78okwvY5wPdzcb1UYnip1pvrZNIVEIh/Cm+ZuvsUYIg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= @@ -53,13 +35,7 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= diff --git a/main.go b/main.go index 0fabac3..18fe1d8 100644 --- a/main.go +++ b/main.go @@ -236,7 +236,7 @@ func main() { { ctx, cancel := context.WithCancel(context.Background()) g.Add(func() error { - r, err := runner.NewRunner(ctx, *getInsecure, *goCmd) + r, err := runner.NewRunner(ctx, logger, *getInsecure, *goCmd) if err != nil { return err } diff --git a/pkg/bingo/mod_test.go b/pkg/bingo/mod_test.go index 1f14082..ae5a773 100644 --- a/pkg/bingo/mod_test.go +++ b/pkg/bingo/mod_test.go @@ -26,7 +26,8 @@ func TestCreateFromExistingOrNew(t *testing.T) { testutil.Ok(t, err) t.Cleanup(func() { testutil.Ok(t, os.RemoveAll(tmpDir)) }) - r, err := runner.NewRunner(context.TODO(), false, "go") + logger := log.New(os.Stderr, "", 0) + r, err := runner.NewRunner(context.TODO(), logger, false, "go") testutil.Ok(t, err) t.Run("create new and close should create empty mod file with basic autogenerated meta", func(t *testing.T) { diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index fe6b70a..e9efc71 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -8,12 +8,14 @@ import ( "context" "fmt" "io" + "log" "os" "os/exec" "path/filepath" "strings" "github.com/Masterminds/semver" + "github.com/bwplotka/bingo/pkg/version" "github.com/pkg/errors" ) @@ -24,6 +26,8 @@ type Runner struct { verbose bool goVersion *semver.Version + + logger *log.Logger } func parseGoVersion(goVersionOutput string) (*semver.Version, error) { @@ -39,18 +43,19 @@ func parseGoVersion(goVersionOutput string) (*semver.Version, error) { } func isSupportedVersion(v *semver.Version) error { - if !v.LessThan(semver.MustParse("1.14")) { + if !v.LessThan(version.Go114) { return nil } return errors.Errorf("found unsupported go version: %v; requires go 1.14.x or higher", v.String()) } // NewRunner checks Go version compatibility then returns Runner. -func NewRunner(ctx context.Context, insecure bool, goCmd string) (*Runner, error) { +func NewRunner(ctx context.Context, logger *log.Logger, insecure bool, goCmd string) (*Runner, error) { output := &bytes.Buffer{} r := &Runner{ goCmd: goCmd, insecure: insecure, + logger: logger, } if err := r.execGo(ctx, output, "", "", "version"); err != nil { @@ -115,16 +120,18 @@ func (r *Runner) exec(ctx context.Context, output io.Writer, cd string, command return errors.Errorf("error while running command '%s %s'; err: %v", command, strings.Join(args, " "), err) } if r.verbose { - fmt.Printf("exec '%s %s'\n", command, strings.Join(args, " ")) + r.logger.Printf("exec '%s %s'\n", command, strings.Join(args, " ")) } return nil } type Runnable interface { + GoVersion() *semver.Version List(update GetUpdatePolicy, args ...string) (string, error) GetD(update GetUpdatePolicy, packages ...string) (string, error) Build(pkg, out string) error GoEnv(args ...string) (string, error) + ModDownload() error } type runnable struct { @@ -163,6 +170,10 @@ const ( UpdatePatchPolicy = GetUpdatePolicy("-u=patch") ) +func (r *runnable) GoVersion() *semver.Version { + return r.r.GoVersion() +} + // List runs `go list` against separate go modules files if any. func (r *runnable) List(update GetUpdatePolicy, args ...string) (string, error) { a := []string{"list"} @@ -211,9 +222,27 @@ func (r *runnable) Build(pkg, out string) error { trimmed := strings.TrimSpace(output.String()) if r.r.verbose && trimmed != "" { - // TODO(bwplotka): Pass logger. - fmt.Println(trimmed) + r.r.logger.Println(trimmed) } return nil +} +// ModDownload runs 'go mod download' against separate go modules file. +func (r *runnable) ModDownload() error { + args := []string{"mod", "download"} + if r.r.verbose { + args = append(args, "-x") + } + args = append(args, fmt.Sprintf("-modfile=%s", r.modFile)) + + out := &bytes.Buffer{} + if err := r.r.execGo(r.ctx, out, r.dir, r.modFile, args...); err != nil { + return errors.Wrap(err, out.String()) + } + + trimmed := strings.TrimSpace(out.String()) + if r.r.verbose && trimmed != "" { + r.r.logger.Println(trimmed) + } + return nil } diff --git a/pkg/version/version.go b/pkg/version/version.go index be83e28..5348810 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -3,5 +3,12 @@ package version +import "github.com/Masterminds/semver" + // Version returns 'bingo' version. -const Version = "v0.3.1" +const Version = "v0.4.0" + +var ( + Go114 = semver.MustParse("1.14") + Go116 = semver.MustParse("1.16") +) diff --git a/testdata/testproject_with_bingo_v0_3_2/.bingo/.gitignore b/testdata/testproject_with_bingo_v0_3_2/.bingo/.gitignore new file mode 100755 index 0000000..4f2055b --- /dev/null +++ b/testdata/testproject_with_bingo_v0_3_2/.bingo/.gitignore @@ -0,0 +1,12 @@ + +# Ignore everything +* + +# But not these files: +!.gitignore +!*.mod +!README.md +!Variables.mk +!variables.env + +*tmp.mod diff --git a/testdata/testproject_with_bingo_v0_3_2/.bingo/README.md b/testdata/testproject_with_bingo_v0_3_2/.bingo/README.md new file mode 100755 index 0000000..7a5c2d4 --- /dev/null +++ b/testdata/testproject_with_bingo_v0_3_2/.bingo/README.md @@ -0,0 +1,14 @@ +# Project Development Dependencies. + +This is directory which stores Go modules with pinned buildable package that is used within this repository, managed by https://github.com/bwplotka/bingo. + +* Run `bingo get` to install all tools having each own module file in this directory. +* Run `bingo get ` to install that have own module file in this directory. +* For Makefile: Make sure to put `include .bingo/Variables.mk` in your Makefile, then use $() variable where is the .bingo/.mod. +* For shell: Run `source .bingo/variables.env` to source all environment variable for each tool. +* For go: Import `.bingo/variables.go` to for variable names. +* See https://github.com/bwplotka/bingo or -h on how to add, remove or change binaries dependencies. + +## Requirements + +* Go 1.14+ diff --git a/testdata/testproject_with_bingo_v0_3_2/.bingo/Variables.mk b/testdata/testproject_with_bingo_v0_3_2/.bingo/Variables.mk new file mode 100644 index 0000000..2d4eabf --- /dev/null +++ b/testdata/testproject_with_bingo_v0_3_2/.bingo/Variables.mk @@ -0,0 +1,67 @@ +# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.3.2. DO NOT EDIT. +# All tools are designed to be build inside $GOBIN. +BINGO_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +GOPATH ?= $(shell go env GOPATH) +GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin +GO ?= $(shell which go) + +# Bellow generated variables ensure that every time a tool under each variable is invoked, the correct version +# will be used; reinstalling only if needed. +# For example for buildable variable: +# +# In your main Makefile (for non array binaries): +# +#include .bingo/Variables.mk # Assuming -dir was set to .bingo . +# +#command: $(BUILDABLE) +# @echo "Running buildable" +# @$(BUILDABLE) +# +BUILDABLE := $(GOBIN)/buildable-v0.0.0-20210109094001-375d0606849d +$(BUILDABLE): $(BINGO_DIR)/buildable.mod + @# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. + @echo "(re)installing $(GOBIN)/buildable-v0.0.0-20210109094001-375d0606849d" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=buildable.mod -o=$(GOBIN)/buildable-v0.0.0-20210109094001-375d0606849d "github.com/bwplotka/bingo/testdata/module/buildable" + +BUILDABLE2 := $(GOBIN)/buildable2-v0.0.0-20210109093942-2e6391144e85 +$(BUILDABLE2): $(BINGO_DIR)/buildable2.mod + @# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. + @echo "(re)installing $(GOBIN)/buildable2-v0.0.0-20210109093942-2e6391144e85" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=buildable2.mod -o=$(GOBIN)/buildable2-v0.0.0-20210109093942-2e6391144e85 "github.com/bwplotka/bingo/testdata/module/buildable2" + +BUILDABLE_OLD := $(GOBIN)/buildable_old-v0.0.0-20210109093942-2e6391144e85 +$(BUILDABLE_OLD): $(BINGO_DIR)/buildable_old.mod + @# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. + @echo "(re)installing $(GOBIN)/buildable_old-v0.0.0-20210109093942-2e6391144e85" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=buildable_old.mod -o=$(GOBIN)/buildable_old-v0.0.0-20210109093942-2e6391144e85 "github.com/bwplotka/bingo/testdata/module/buildable" + +F2_ARRAY := $(GOBIN)/f2-v1.5.0 $(GOBIN)/f2-v1.1.0 $(GOBIN)/f2-v1.2.0 $(GOBIN)/f2-v1.0.0 +$(F2_ARRAY): $(BINGO_DIR)/f2.mod $(BINGO_DIR)/f2.1.mod $(BINGO_DIR)/f2.2.mod $(BINGO_DIR)/f2.3.mod + @# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. + @echo "(re)installing $(GOBIN)/f2-v1.5.0" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=f2.mod -o=$(GOBIN)/f2-v1.5.0 "github.com/fatih/faillint" + @echo "(re)installing $(GOBIN)/f2-v1.1.0" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=f2.1.mod -o=$(GOBIN)/f2-v1.1.0 "github.com/fatih/faillint" + @echo "(re)installing $(GOBIN)/f2-v1.2.0" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=f2.2.mod -o=$(GOBIN)/f2-v1.2.0 "github.com/fatih/faillint" + @echo "(re)installing $(GOBIN)/f2-v1.0.0" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=f2.3.mod -o=$(GOBIN)/f2-v1.0.0 "github.com/fatih/faillint" + +FAILLINT := $(GOBIN)/faillint-v1.3.0 +$(FAILLINT): $(BINGO_DIR)/faillint.mod + @# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. + @echo "(re)installing $(GOBIN)/faillint-v1.3.0" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=faillint.mod -o=$(GOBIN)/faillint-v1.3.0 "github.com/fatih/faillint" + +GO_BINDATA := $(GOBIN)/go-bindata-v3.1.1+incompatible +$(GO_BINDATA): $(BINGO_DIR)/go-bindata.mod + @# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. + @echo "(re)installing $(GOBIN)/go-bindata-v3.1.1+incompatible" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=go-bindata.mod -o=$(GOBIN)/go-bindata-v3.1.1+incompatible "github.com/go-bindata/go-bindata/go-bindata" + +WR_BUILDABLE := $(GOBIN)/wr_buildable-v0.0.0-20210109165512-ccbd4039b94a +$(WR_BUILDABLE): $(BINGO_DIR)/wr_buildable.mod + @# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. + @echo "(re)installing $(GOBIN)/wr_buildable-v0.0.0-20210109165512-ccbd4039b94a" + @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=wr_buildable.mod -o=$(GOBIN)/wr_buildable-v0.0.0-20210109165512-ccbd4039b94a "github.com/bwplotka/bingo/testdata/module_with_replace/buildable" + diff --git a/testdata/testproject_with_bingo_v0_3_2/.bingo/buildable.mod b/testdata/testproject_with_bingo_v0_3_2/.bingo/buildable.mod new file mode 100644 index 0000000..1b2c9bf --- /dev/null +++ b/testdata/testproject_with_bingo_v0_3_2/.bingo/buildable.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.16 + +require github.com/bwplotka/bingo/testdata/module v0.0.0-20210109094001-375d0606849d // buildable diff --git a/testdata/testproject_with_bingo_v0_3_2/.bingo/buildable2.mod b/testdata/testproject_with_bingo_v0_3_2/.bingo/buildable2.mod new file mode 100644 index 0000000..f46a81c --- /dev/null +++ b/testdata/testproject_with_bingo_v0_3_2/.bingo/buildable2.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.16 + +require github.com/bwplotka/bingo/testdata/module v0.0.0-20210109093942-2e6391144e85 // buildable2 diff --git a/testdata/testproject_with_bingo_v0_3_2/.bingo/buildable_old.mod b/testdata/testproject_with_bingo_v0_3_2/.bingo/buildable_old.mod new file mode 100644 index 0000000..4a9de2b --- /dev/null +++ b/testdata/testproject_with_bingo_v0_3_2/.bingo/buildable_old.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.16 + +require github.com/bwplotka/bingo/testdata/module v0.0.0-20210109093942-2e6391144e85 // buildable diff --git a/testdata/testproject_with_bingo_v0_3_2/.bingo/f2.1.mod b/testdata/testproject_with_bingo_v0_3_2/.bingo/f2.1.mod new file mode 100644 index 0000000..97b0929 --- /dev/null +++ b/testdata/testproject_with_bingo_v0_3_2/.bingo/f2.1.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.16 + +require github.com/fatih/faillint v1.1.0 diff --git a/testdata/testproject_with_bingo_v0_3_2/.bingo/f2.2.mod b/testdata/testproject_with_bingo_v0_3_2/.bingo/f2.2.mod new file mode 100644 index 0000000..e384eac --- /dev/null +++ b/testdata/testproject_with_bingo_v0_3_2/.bingo/f2.2.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.16 + +require github.com/fatih/faillint v1.2.0 diff --git a/testdata/testproject_with_bingo_v0_3_2/.bingo/f2.3.mod b/testdata/testproject_with_bingo_v0_3_2/.bingo/f2.3.mod new file mode 100644 index 0000000..a169d91 --- /dev/null +++ b/testdata/testproject_with_bingo_v0_3_2/.bingo/f2.3.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.16 + +require github.com/fatih/faillint v1.0.0 diff --git a/testdata/testproject_with_bingo_v0_3_2/.bingo/f2.mod b/testdata/testproject_with_bingo_v0_3_2/.bingo/f2.mod new file mode 100644 index 0000000..d9fcad1 --- /dev/null +++ b/testdata/testproject_with_bingo_v0_3_2/.bingo/f2.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.16 + +require github.com/fatih/faillint v1.5.0 diff --git a/testdata/testproject_with_bingo_v0_3_2/.bingo/faillint.mod b/testdata/testproject_with_bingo_v0_3_2/.bingo/faillint.mod new file mode 100644 index 0000000..acb7811 --- /dev/null +++ b/testdata/testproject_with_bingo_v0_3_2/.bingo/faillint.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.16 + +require github.com/fatih/faillint v1.3.0 diff --git a/testdata/testproject_with_bingo_v0_3_2/.bingo/go-bindata.mod b/testdata/testproject_with_bingo_v0_3_2/.bingo/go-bindata.mod new file mode 100644 index 0000000..4f79d57 --- /dev/null +++ b/testdata/testproject_with_bingo_v0_3_2/.bingo/go-bindata.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.16 + +require github.com/go-bindata/go-bindata v3.1.1+incompatible // go-bindata diff --git a/testdata/testproject_with_bingo_v0_3_2/.bingo/go.mod b/testdata/testproject_with_bingo_v0_3_2/.bingo/go.mod new file mode 100755 index 0000000..610249a --- /dev/null +++ b/testdata/testproject_with_bingo_v0_3_2/.bingo/go.mod @@ -0,0 +1 @@ +module _ // Fake go.mod auto-created by 'bingo' for go -moddir compatibility with non-Go projects. Commit this file, together with other .mod files. \ No newline at end of file diff --git a/testdata/testproject_with_bingo_v0_3_2/.bingo/variables.env b/testdata/testproject_with_bingo_v0_3_2/.bingo/variables.env new file mode 100644 index 0000000..c6b8d5b --- /dev/null +++ b/testdata/testproject_with_bingo_v0_3_2/.bingo/variables.env @@ -0,0 +1,24 @@ +# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.3.2. DO NOT EDIT. +# All tools are designed to be build inside $GOBIN. +# Those variables will work only until 'bingo get' was invoked, or if tools were installed via Makefile's Variables.mk. +GOBIN=${GOBIN:=$(go env GOBIN)} + +if [ -z "$GOBIN" ]; then + GOBIN="$(go env GOPATH)/bin" +fi + + +BUILDABLE="${GOBIN}/buildable-v0.0.0-20210109094001-375d0606849d" + +BUILDABLE2="${GOBIN}/buildable2-v0.0.0-20210109093942-2e6391144e85" + +BUILDABLE_OLD="${GOBIN}/buildable_old-v0.0.0-20210109093942-2e6391144e85" + +F2_ARRAY="${GOBIN}/f2-v1.5.0 ${GOBIN}/f2-v1.1.0 ${GOBIN}/f2-v1.2.0 ${GOBIN}/f2-v1.0.0" + +FAILLINT="${GOBIN}/faillint-v1.3.0" + +GO_BINDATA="${GOBIN}/go-bindata-v3.1.1+incompatible" + +WR_BUILDABLE="${GOBIN}/wr_buildable-v0.0.0-20210109165512-ccbd4039b94a" + diff --git a/testdata/testproject_with_bingo_v0_3_2/.bingo/wr_buildable.mod b/testdata/testproject_with_bingo_v0_3_2/.bingo/wr_buildable.mod new file mode 100644 index 0000000..29eda26 --- /dev/null +++ b/testdata/testproject_with_bingo_v0_3_2/.bingo/wr_buildable.mod @@ -0,0 +1,7 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.16 + +replace github.com/bwplotka/bingo => github.com/pkg/errors v0.9.1 + +require github.com/bwplotka/bingo/testdata/module_with_replace v0.0.0-20210109165512-ccbd4039b94a // buildable