-1
  • The location: github.com/elastic/beats
  • The mod file: github.com/elastic/beats/go.mod
  • The module name: github.com/elastic/beats/v7
  • The tag: v7.10.2

What LoTR incantation of go get to I have to run to get a little dependency update action?

bschaeffer
  • 2,824
  • 1
  • 29
  • 59

2 Answers2

2

This will update to latest minor.patch version of v7:

go get github.com/elastic/beats/v7

or if you want a specific version to update/downgrade to:

go get github.com/elastic/beats/v7@v7.10.2

Adding the -u flag will additionally update the dependencies of github.com/elastic/beats/v7:

go get -u github.com/elastic/beats/v7

TehSphinX
  • 6,536
  • 1
  • 24
  • 34
  • `$ go get github.com/elastic/beats/v7@v7.10.2 build github.com/elastic/beats/v7: cannot load github.com/elastic/beats/v7: no Go source files` – bschaeffer Jan 21 '21 at 15:46
  • 1
    The `no Go source files` error was a variant of https://golang.org/issue/44106, addressed in (the newly-released) Go 1.16. – bcmills Feb 17 '21 at 14:48
  • 1
    The issue was triggered by a [tag-constrained source file](https://github.com/elastic/beats/blob/4a1f8007f11fef73ab2de1dbbf3a68cc096d7d1b/magefile.go) at the root of the module: `go get` thought that you wanted to actually build the _package_ `github.com/elastic/beats/v7`, but that package can only be built with `-tags mage` set. – bcmills Feb 17 '21 at 14:56
2

The argument list passed to go get should generally be a list of package paths or patterns, not just a module path.

For example, you might invoke:

go get -d github.com/elastic/beats/v7/libbeat/beat@latest

in order to obtain the latest version of package …/libbeat/beat and also download any transitive dependencies needed for that package.

(You can pass just a module path, and that should also update the version of the dependency module overall, but it will not download source code or module checksums for transitive dependencies that may be needed in order to build the updated package. go get does not in general know which transitive dependencies will be relevant to the commands that you plan to invoke after it, and it does not do extra work to speculatively identify relevant dependencies.)

bcmills
  • 4,391
  • 24
  • 34