Find out the version of Go a Binary was built with

2020-08-09 07:38发布

Is there a way to tell what go version a binary was built with?

I have multiple go instances on my workstation, so I want to verify that the correct one was used.

标签: go
3条回答
我想做一个坏孩纸
2楼-- · 2020-08-09 07:51

Use go version <path>.

$ go version /usr/bin/syncthing
/usr/bin/syncthing: go1.13.10

$ go version
go version go1.14.3 linux/amd64
查看更多
戒情不戒烟
3楼-- · 2020-08-09 07:57

Use runtime.Version() at runtime to figure out what version of Go your binary was built with:

func Version() string

Version returns the Go tree's version string. It is either a sequence number or, when possible, a release tag like "release.2010-03-04". A trailing + indicates that the tree had local modifications at the time of the build.

查看更多
来,给爷笑一个
4楼-- · 2020-08-09 07:59

The following command should do it:

# strings binary_path | grep 'go1\.' 
go1.5.3
查看更多
登录 后发表回答