Find outdated dependencies of your Go projects. go-mod-outdated provides a table view of the go list -u -m -json all command which lists all dependencies of a G
Find outdated dependencies of your Go projects. go-mod-outdated provides a table view of the go list -u -m -json all command which lists all dependencies of a G
An easy way to find outdated dependencies of your Go projects.
go-mod-outdated provides a table view of the go list -u -m -json all command which lists all dependencies of a Go project and their available minor and patch updates. It also provides a way to filter indirect dependencies and dependencies without updates.
In short it turns this:
…into this
…You are welcome to contribute bug fixes or improvements.
go install github.com/psampaz/go-mod-outdated@latestIn the folder where your go.mod lives run
go list -u -m -json all | go-mod-outdatedto see all modules in table view.
If you want to see only the modules with updates run
go list -u -m -json all | go-mod-outdated -updateIf you want to see only the direct depedencies run
go list -u -m -json all | go-mod-outdated -directIf you want to see only the direct depedencies that have updates run
go list -u -m -json all | go-mod-outdated -update -direct To output a markdown compatible table, pass the -style markdown option
go list -u -m -json all | go-mod-outdated -style markdown Important note for Go 1.14 users
If are using Go 1.14 with vendoring you need to pass -mod=mod or -mod=readonly to the go list command otherwise you will get the following error:
$ go list -u -m -json all
go list -m: can't determine available upgrades using the vendor directory
(Use -mod=mod or -mod=readonly to bypass.)The following will work:
go list -u -m -mod=mod -json all | go-mod-outdated go list -u -m -mod=readonly -json all | go-mod-outdatedIn the folder where your go.mod lives run
go list -u -m -json all | docker run --rm -i psampaz/go-mod-outdatedTo use parameters just append
go list -u -m -json all | docker run --rm -i psampaz/go-mod-outdated -updateUsing the -ci flag will the make the command exit with none zero code, breaking this way your ci pipelines.
If you want to make your CI pipeline fail if any direct or indirect dependency is outdated use the following:
go list -u -m -json all | go-mod-outdated -ciIf you want to make your CI pipeline fail only if a direct dependency is outdated use the following:
go list -u -m -json all | go-mod-outdated -direct -ciIn order to see details about the usage of the command use the -h or -help flag
$ go-mod-outdated -help
Usage of go-mod-outdated:
-direct
List only direct modules
-update
List only modules with updates
-ci
Non-zero exit code when at least one outdated dependency was found
-style string
Output style, pass 'markdown' for a Markdown table (default "default")If go list -u -m -json all | go-mod-outdated -update -direct seems too difficult to use or remember you can create a shortcut using an alias. In linux try one of the following:
alias gmo="go list -u -m -json all | go-mod-outdated"
alias gmod="go list -u -m -json all | go-mod-outdated -direct"
alias gmou="go list -u -m -json all | go-mod-outdated -update"
alias gmodu="go list -u -m -json all | go-mod-outdated -direct -update"There is a case where the updated version reported by the go list command is actually older than the current one.
go-mod-outdated output includes a column named VALID TIMESTAMP which will give an indication when this case happens, helping application maintainers to avoid upgrading to a version that will break their application.
The following example is based on Hugo's go.mod (v0.53) (https://raw.githubusercontent.com/gohugoio/hugo/v0.53/go.mod)
……………No open issues yet, or sync has not completed.