Ain't Go 1.13's "go get -u" does exactly this?
And the old behaviour with "go get -u all" ?

"The -u flag instructs get to update modules providing dependencies of 
packages named on the command line to use newer minor or patch releases 
when available. Continuing the previous example, 'go get -u A' will use the 
latest A with B v1.3.1 (not B v1.2.3). If B requires module C, but C does 
not provide any packages needed to build packages in A (not including 
tests), then C will not be updated."

"With no package arguments, 'go get' applies to Go package in the current 
directory, if any. In particular, 'go get -u' and 'go get -u=patch' update 
all the dependencies of that package."

2019. szeptember 5., csütörtök 1:35:58 UTC+2 időpontban 
a következőt írta:
> Hello,
> I am looking for a way to regularly update my Go module's direct 
> dependencies. Without specifying indirect dependencies myself: let my 
> direct dependencies specify what they need in their own go.mod.
> After reading relevant documentation, I could only come up with this 
> partial workaround:
> go list -m -u -f '{{if and (and (not .Indirect) (not .Main)) 
> .Update}}{{.Path}}@{{.Update.Version}}{{end}}' all | xargs 
> --no-run-if-empty go get
> Suspecting this scenario is common and useful, I have prepared a minimal 
> concrete example below (each module is a repository under 
> for now).
> "X → Y" means "module X depends directly on module Y".
> I have the following Go modules:
> goMain → goA → goB
> goMain's tests → goT
> All modules have published versions v1.1.0, v1.2.0 and v2.0.0 (except 
> goMain which has no version tags). All dependency arrows above (go.mod 
> entries) specify v1.1.0, so all can be updated.
> goMain's .go files are in a sub/dir/ to make sure the commands I type 
> inspect all packages inside the module, but this isn't mandatory: I can 
> also repeat a command in each package's directory if needed.
> --------
> In goMain:
> $ cat go.mod 
> module
> go 1.13
> require (
> v1.1.0
> v1.1.0
> )
> --------
> 1) How to find out if goA or goT have a newer v1 version, and update to it?
> My 'go list … | xargs …' workaround above does this by listing the direct 
> dependencies and passing them to 'go get'.
> Would it make sense to support this functionality via a shorter command?
> I cannot use 'go get -u -t -d ./...' here because that brings in the 
> indirect dependency 'goB' into my go.mod.
> 2) How to find out if goA or goT have a newer major version (v2 or later)?
> I know that v2 and later have a different import path (ending in "/v2"), 
> so different major versions are different packages and they can be used 
> together in my module.
> But I would like a command which tells me if some of my direct 
> dependencies have a newer major version, otherwise I would have to check 
> each dependency by hand to find out.
> Mihai

You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To view this discussion on the web visit

Reply via email to