'Get golang version from compiled binary
Is there a way to get golang version from pkg/ or from compiled binary?
I want to automate removal of $GOPATH/pkg folder only when I change the golang version.
Solution 1:[1]
With 1.9.2, the grep command is
strings $pkg_a_file | grep 'Go cmd/compile'
Solution 2:[2]
I found the following method, to check the version of Go lib used to compile the binary
$ strings compiled_binary | grep '^go1'
go1.17.4
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | pinguin666 |
| Solution 2 | anotherGatsby |
