go-mod-outdated - A tool to find outdated dependencies on Go projects

2019/05/01

Recently at work, I was trying to update some Go projects using new module system and I was looking for an easy way to preview the available updates, something similar to Composer’s composer show -outdated command. The closest to this that currently exists in the Go toolchain is the

go list -m -u all

command, which outputs minor and patch updates in plain text format (one line per update).

golang.org/x/text v0.3.0 [v0.4.0] => /tmp/text
rsc.io/pdf v0.1.1 [v0.1.2]

The interesting thing is that if you pass the -json flag then output is converted to json and that means that can be easily parsed.

But still, I was missing a tabular view that could make the output human readable. So go-mod-outdated was born which can turn

{
    "Path": "github.com/BurntSushi/locker",
    "Version": "v0.0.0-20171006230638-a6e239ea1c69",
    "Time": "2017-10-06T23:06:38Z",
    "GoMod": "/home/mojo/go/pkg/mod/cache/download/github.com/!burnt!sushi/locker/@v/v0.0.0-20171006230638-a6e239ea1c69.mod"
}
{
    "Path": "github.com/BurntSushi/toml",
    "Version": "v0.0.0-20170626110600-a368813c5e64",
    "Time": "2017-06-26T11:06:00Z",
    "Update": {
        "Path": "github.com/BurntSushi/toml",
        "Version": "v0.3.1",
        "Time": "2018-08-15T10:47:33Z"
    },
    "GoMod": "/home/mojo/go/pkg/mod/cache/download/github.com/!burnt!sushi/toml/@v/v0.0.0-20170626110600-a368813c5e64.mod"
}

into this

+-------------------------------------------+--------------------------------------+------------------------------------+--------+------------------+
|                  MODULE                   |               VERSION                |            NEW VERSION             | DIRECT | VALID TIMESTAMPS |
+-------------------------------------------+--------------------------------------+------------------------------------+--------+--------+---------+
| github.com/BurntSushi/locker              | v0.0.0-20171006230638-a6e239ea1c69   |                                    | true   | true             |
| github.com/BurntSushi/toml                | v0.0.0-20170626110600-a368813c5e64   | v0.3.1                             | true   | true             |
+-------------------------------------------+--------------------------------------+------------------------------------+--------+--------+---------+

You can read more about the tool here: https://github.com/psampaz/go-mod-outdated

Categories: posts Tags: go golang