Skip to content

Commit

Permalink
Fixed "Go1.18+ required" error on some modules due to missing go.sum
Browse files Browse the repository at this point in the history
Reason was that go list command no longer updates go.sum.

Fixes: #125

Signed-off-by: bwplotka <bwplotka@gmail.com>
  • Loading branch information
bwplotka committed Feb 19, 2023
1 parent c669a8c commit a3a6789
Show file tree
Hide file tree
Showing 11 changed files with 219 additions and 1,036 deletions.
8 changes: 4 additions & 4 deletions .bingo/Variables.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.7. DO NOT EDIT.
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.8. DO NOT EDIT.
# All tools are designed to be build inside $GOBIN.
BINGO_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
GOPATH ?= $(shell go env GOPATH)
Expand Down Expand Up @@ -41,11 +41,11 @@ $(GOIMPORTS): $(BINGO_DIR)/goimports.mod
@echo "(re)installing $(GOBIN)/goimports-v0.0.0-20210112230658-8b4aab62c064"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=goimports.mod -o=$(GOBIN)/goimports-v0.0.0-20210112230658-8b4aab62c064 "golang.org/x/tools/cmd/goimports"

GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.50.0
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.51.0
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.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)/golangci-lint-v1.50.0"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.50.0 "github.com/golangci/golangci-lint/cmd/golangci-lint"
@echo "(re)installing $(GOBIN)/golangci-lint-v1.51.0"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.51.0 "github.com/golangci/golangci-lint/cmd/golangci-lint"

MDOX := $(GOBIN)/mdox-v0.9.0
$(MDOX): $(BINGO_DIR)/mdox.mod
Expand Down
4 changes: 2 additions & 2 deletions .bingo/golangci-lint.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.14
go 1.20

require github.com/golangci/golangci-lint v1.50.0 // cmd/golangci-lint
require github.com/golangci/golangci-lint v1.51.0 // cmd/golangci-lint
954 changes: 123 additions & 831 deletions .bingo/golangci-lint.sum

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions .bingo/proxy.sum
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+
github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/mux v1.6.2 h1:Pgr17XVTNXAk3q/r4CpKzC5xBM/qW1uVLV+IhRZpIIk=
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
Expand Down Expand Up @@ -181,12 +182,14 @@ github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeY
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kelseyhightower/envconfig v1.3.0 h1:IvRS4f2VcIQy6j4ORGIf9145T/AsUB+oY8LyvN8BXNM=
github.com/kelseyhightower/envconfig v1.3.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
Expand Down Expand Up @@ -324,6 +327,7 @@ golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE
golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6 h1:QE6XYQK6naiK1EPAe1g/ILLxN5RBoH5xkJk3CqlMI/Y=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
Expand All @@ -335,6 +339,7 @@ golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHl
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
golang.org/x/lint v0.0.0-20200130185559-910be7a94367 h1:0IiAsCRByjO2QjX7ZPkw5oU9x+n1YqRL802rjC0c3Aw=
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
Expand Down Expand Up @@ -420,6 +425,7 @@ golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapK
golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200224181240-023911ca70b2 h1:L/G4KZvrQn7FWLN/LlulBtBzrLUhqjiGfTWWDmrh+IQ=
golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand All @@ -439,6 +445,7 @@ google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9Ywl
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180608181217-32ee49c4dd80/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
Expand Down Expand Up @@ -490,6 +497,7 @@ honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
4 changes: 2 additions & 2 deletions .bingo/variables.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.7. DO NOT EDIT.
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.8. 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)}
Expand All @@ -16,7 +16,7 @@ FAILLINT="${GOBIN}/faillint-v1.8.0"

GOIMPORTS="${GOBIN}/goimports-v0.0.0-20210112230658-8b4aab62c064"

GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.50.0"
GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.51.0"

MDOX="${GOBIN}/mdox-v0.9.0"

Expand Down
150 changes: 1 addition & 149 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,151 +1,3 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

NOTE: As semantic versioning states all 0.y.z releases can contain breaking changes in API (flags, grpc API, any backward compatibility)

We use *breaking* word for marking changes that are not backward compatible (relates only to v0.y.z releases.)

## Unreleased

## [v0.6](https://github.com/bwplotka/bingo/releases/tag/v0.6) - 2022.04.23

* Fixed support for MacOS and Go1.18
* Removed `-u` and `-upatch` options which did not work correctly. `@latest` can be used instead.
* Better error message when attempting to build forks.

## [v0.5.2](https://github.com/bwplotka/bingo/releases/tag/v0.5.2) - 2021.12.21

### Added

* Added back go sum files for each pinned go tool for extra security (check sums).

### Fixed

* Fixed support for modules / packages with upper case in it and Go 1.17 logic.
* Fixed support for modules with +incompatible version.

## [v0.5.1](https://github.com/bwplotka/bingo/releases/tag/v0.5.1) - 2021.07.20

### Added

* bingo now auto-fetches `exclude` and `retract` directives from binaries' go modules that have those.

### Changed

* *breaking*: Use `bingo:no_directive_fetch` to disable auto fetch logic (previously: `bingo:no_replace_fetch`)

## [v0.4.3](https://github.com/bwplotka/bingo/releases/tag/v0.4.3) - 2021.05.14

### Fixed

* Fixed panic when calling wrong version with short module name.
* Fixed issue when installing bingo from scratch using `go get`

## [v0.4.2](https://github.com/bwplotka/bingo/releases/tag/v0.4.2) - 2021.05.13

### Added

* bingo list now lists pinned build flags and environment variables.

### Fixed

* Fixed preserving build flags and env files via bingo .mod files.
* Fixed formatting of bingo list

## [v0.4.1](https://github.com/bwplotka/bingo/releases/tag/v0.4.1) - 2021.05.12

### Added

* Added support for build flags and environment variables via go.mod file.

### Fixed

* Generated files have limited permission.
* Support for Go pre-released versions.

## [v0.4.0](https://github.com/bwplotka/bingo/releases/tag/v0.4.0) - 2021.03.24

### Added

* 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

* [Fixed](https://github.com/bwplotka/bingo/issues/65) support for tools with names that have capital letters.

## [v0.3.0](https://github.com/bwplotka/bingo/releases/tag/v0.3.0) - 2021.01.13

### Added

* `-l` flag which also creates a soft link to the currently pinned tool under non versioned <tool> binary name.
* Support easier path changing upgrades of tools with the same name.
* [Automatic download of `replace` entries](https://github.com/bwplotka/bingo/issues/7) for the pinned version of the tool. This is very often required by big projects to fight with deps hell ([Go Modules are hard](https://twitter.com/bwplotka/status/1347104281120403458)). Add `// bingo:no_replace_fetch` comment anywhere in tool mod file if you want to not autogenerate replace commands.

### Fixed

* Simplified and fixed -u cases.
* Fixed various invalid cases for -r and -n options.
* Extended capabilities of verbose mode.

## [v0.2.4](https://github.com/bwplotka/bingo/releases/tag/v0.2.4) - 2020.12.27

### Fixed

* Improved env variables
* Removed -i option from build which was not needed.
* Avoid vendor mode when installing via Makefile

## [v0.2.3](https://github.com/bwplotka/bingo/releases/tag/v0.2.3) - 2020.06.26

### Fixed

* Fixed Go version checker.
* Fixed case with installing latest binary version, when binary was not installed before.

## [v0.2.2](https://github.com/bwplotka/bingo/releases/tag/v0.2.2) - 2020.06.10

### Fixed

* [#25](https://github.com/bwplotka/bingo/issues/25) Fixed support of `bingo get` for arrays.
* Fixed versioning binaries with `+incompatible` version (wrong templating used).
* Fixed support `bingo list` for arrays.
* Added rename / clone logic
* Always print to stdout no matter of verbose level.

### Changed

* `bingo list` output format. (table `\t`-delimited now)

## [v0.2.1](https://github.com/bwplotka/bingo/releases/tag/v0.2.1) - 2020.06.04

### Fixed

* Fixed extra whitespace in variables.env.

## [v0.2.0](https://github.com/bwplotka/bingo/releases/tag/v0.2.0) - 2020.06.04

### Added

* Added `.variables.env` file to bingo moddir for easy export of all environment variables to the current shell. Removed `-m` and `-makefile` flags. Bingo now always creates makefile and env file and never generate `include` to avoid many corner cases. It's now documented how to add `include` in the documentation.

## [v0.1.1](https://github.com/bwplotka/bingo/releases/tag/v0.1.1) - 2020.06.03

### Fixed

* [#22](https://github.com/bwplotka/bingo/pull/22) Fixed problem with running bingo in non-Go project. From now on it also maintains fake go.mod to resolve issues like:

```
`Error: get command failed: 0: getting : go get -d: go: cannot find main module, but -modfile was set.
-modfile cannot be used to set the module root directory.
```

## [v0.1.0](https://github.com/bwplotka/bingo/releases/tag/v0.1.0) - 2020.05.30

Initial release.

Why 0.1.0? Well, because we plan to release 1.0 once we introduce this tool to [Thanos](http://github.com/thanos-io/thanos) and [go-grpc-middleware](https://github.com/grpc-ecosystem/go-grpc-middleware) as the final test (: After having this usage stable for a bit, and we are sure flags will not change, we can claim 1.0.
See [Releases](https://github.com/bwplotka/bingo/releases)
33 changes: 18 additions & 15 deletions get.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,7 @@ func validateTargetName(targetName string) error {
return nil
}

func resolvePackage(
logger *log.Logger,
verbose bool,
tmpModFile string,
runnable runner.Runnable,
target *bingo.Package,
) (err error) {
func resolvePackage(logger *log.Logger, verbose bool, tmpModFile string, runnable runner.Runnable, target *bingo.Package) (err error) {
// Do initial go get -d and remember output.
// 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.
Expand Down Expand Up @@ -595,7 +589,7 @@ func getPackage(ctx context.Context, logger *log.Logger, c installPackageConfig,

outSumFile := strings.TrimSuffix(outModFile, ".mod") + ".sum"

// If we don't have all information or update is set, resolve version.
// If we don't have all information, resolve version.
var fetchedDirectives nonRequireDirectives
if target.Module.Version == "" || !strings.HasPrefix(target.Module.Version, "v") || target.Module.Path == "" {
// Set up totally empty mod file to get clear version to install.
Expand All @@ -620,9 +614,11 @@ func getPackage(ctx context.Context, logger *log.Logger, c installPackageConfig,
}

// Now we should have target with all required info, prepare tmp file.
// TODO(bwplotka): Is this still needed?
if err := cleanGoGetTmpFiles(c.modDir); err != nil {
return err
}

tmpModFile, err := bingo.CreateFromExistingOrNew(ctx, c.runner, logger, outModFile, tmpModFilePath)
if err != nil {
return errors.Wrap(err, "create tmp mod file")
Expand Down Expand Up @@ -755,27 +751,34 @@ func install(ctx context.Context, logger *log.Logger, r *runner.Runner, modDir s
return errors.Wrap(err, pkg.String())
}

// 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.
modCtx := r.With(ctx, modFile.Filepath(), modDir, nil)

// Check if path is pointing to non-buildable package.
var listArgs []string
listArgs = append(listArgs, modFile.DirectPackage().BuildFlags...)
listArgs = append(listArgs, "-mod=mod", "-f={{.Name}}", pkg.Path())
if listOutput, err := r.With(ctx, modFile.Filepath(), modDir, nil).List(listArgs...); err != nil {
if listOutput, err := modCtx.List(listArgs...); err != nil {
return errors.Wrap(err, "list")
} else if !strings.HasSuffix(listOutput, "main") {
return errors.Newf("package %s is non-main (go list output %q), nothing to get and build", pkg.Path(), listOutput)
}

gobin, err := gobin(r.With(ctx, modFile.Filepath(), modDir, nil))
// Use go get -d to recreate .sum file
// TODO(bwplotka): Do it only if not present or if we update mod to new version?
if out, err := modCtx.GetD(modFile.DirectPackage().String()); err != nil {
return errors.Wrap(err, out)
}

gobin, err := gobin(modCtx)
if err != nil {
return errors.Wrap(err, "deduct GOBIN")
}

// go install does not define -modfile flag so we mimic go install with go build -o instead.
// go install does not define -modfile flag, so we mimic go install with go build -o instead.
binPath := filepath.Join(gobin, fmt.Sprintf("%s-%s", name, pkg.Module.Version))

modCtx := r.With(ctx, modFile.Filepath(), modDir, pkg.BuildEnvs)
// New context with new environment files.
modCtx = r.With(ctx, modFile.Filepath(), modDir, pkg.BuildEnvs)
if err := modCtx.Build(pkg.Path(), binPath, pkg.BuildFlags...); err != nil {
if strings.Contains(err.Error(), "module declares its path as: ") &&
strings.Contains(err.Error(), fmt.Sprintf("but was required as: %v", modFile.DirectPackage().Path())) {
Expand Down
18 changes: 18 additions & 0 deletions get_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,24 @@ func TestGet_ModuleCases(t *testing.T) {

// Tricky cases TODO.

// Regression against https://github.com/bwplotka/bingo/issues/125
//t.Run("golangcilint", func(t *testing.T) {
// g.Clear(t)
//
// 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"), true)
// p.assertNotChanged(t)
//
// // We manually build bingo binary to make sure GOCACHE will not hit us.
// bingoPath := filepath.Join(g.tmpDir, bingoBin)
// buildInitialGobin(t, bingoPath)
//
// expectBingoListRows(t, []row(nil), g.ExecOutput(t, p.root, bingoPath, "list"))
// testutil.Equals(t, []string{}, g.existingBinaries(t))
//
// fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.1"))
//})

// // Regression test against https://github.com/bwplotka/bingo/issues/65.
// name: "get tool with capital letters in name",
// do: func(t *testing.T, g *goEnv, p *testProject) {
Expand Down
Loading

0 comments on commit a3a6789

Please sign in to comment.