golang[80]-项目查看过时mod

I’m working on a large (oldish) project that I’ve just migrated to go modules ✅ The conversion of the old vendored files (govendor) has produced a large go.mod file with about 100 direct requires.

Is there a tool/way of going through this list of requires and printing current version versus latest github version (ie find out-of-date modules)? For example:

1
2
3
4
5
6
7
8
require (
github.com/foo/bar v1.2.0
...
)
The latest tagged version of foo/bar on github is v1.3.1, I'd like to get a list like:

package current latest
github.com/foo/bar v1.2.0 v1.3.1

解决方案

1
2
3
4
5
6
go list -m -u all | column -t

fubar
cloud.google.com/go v0.26.0 [v0.40.0]
github.com/BurntSushi/toml v0.3.1
github.com/PuerkitoBio/purell v1.1.0 [v1.1.1]

查看版本依赖

下面可以看出项目依赖了protobuf@v1.2.0版本

1
2
3
4
5
6
7
8
9
> go mod graph | grep github.com/golang/protobuf      

gitlab.followme.com/FollowmeGo/utils@v0.0.0-20190608152033-4ef278ca4fca github.com/golang/protobuf@v1.2.0
gopkg.in/gorethink/gorethink.v4@v4.1.0 github.com/golang/protobuf@v1.2.0
github.com/hashicorp/go-discover@v0.0.0-20190117190025-e88f86e24f50 github.com/golang/protobuf@v1.2.0
github.com/hashicorp/go-plugin@v0.0.0-20190212232519-b838ffee39ce github.com/golang/protobuf@v1.2.0
github.com/onsi/gomega@v1.4.3 github.com/golang/protobuf@v1.2.0
google.golang.org/appengine@v1.2.0 github.com/golang/protobuf@v1.2.0
github.com/hashicorp/go-plugin@v0.0.0-20181030172320-54b6ff97d818 github.com/golang/protobuf@v1.2.0

参考

https://www.reddit.com/r/golang/comments/c00fw6/finding_whats_outofdate_in_gomod/