Fix CLI version when installed it using `go`
dobarx opened this issue · 0 comments
dobarx commented
Fabric CLI can already be installed using go
command:
$ go install github.com/blackstork-io/fabric@latest
# or
$ go install github.com/blackstork-io/fabric@v0.4.0-rev0
But the version is always set to:
$ fabric --version
fabric version v0.0.0-dev
We can use runtime/debug
std package and retrieve main
module version. For example:
package main
import "runtime/debug"
var version string
func main() {
// ...
}
func init() {
info, ok := debug.ReadBuildInfo()
if !ok {
version = "0.0.0-dev"
return
}
version = info.Main.Version
}