
* cmd/dlv: dlv version --verbose That prints out runtime/debug.BuildInfo read from the dlv binary. Users can retrieve the same info using `go version -m <path_to_dlv>` but I think it is convenient to have. If dlv was built from cloned delve repo: ``` $ ./dlv version -v Delve Debugger Version: 1.7.0 Build: $Id: e353a65161e6ed74952b96bbb62ebfc56090832b $ Build Details: go1.16.5 mod github.com/go-delve/delve (devel) dep github.com/cosiner/argv v0.1.0 h1:BVDiEL32lwHukgJKP87btEPenzrrHUjajs/8yzaqcXg= ... ``` If dlv was built with `go install github.com/go-delve/delve@latest` with go1.16+, or `GO111MODULE=on go get github.com/go-delve/delve@latest` from a clean main module: ``` $ ./dlv version -v Delve Debugger Version: 1.7.0 Build: $Id: e353a65161e6ed74952b96bbb62ebfc56090832b $ Build Details: go1.16.5 mod github.com/go-delve/delve v1.7.0 dep github.com/cosiner/argv v0.1.0 h1:BVDiEL32lwHukgJKP87btEPenzrrHUjajs/8yzaqcXg= ... ``` * remove an accidentally added bogus test
33 lines
641 B
Go
33 lines
641 B
Go
// +build go1.12
|
|
|
|
package version
|
|
|
|
import (
|
|
"bytes"
|
|
"runtime/debug"
|
|
"text/template"
|
|
)
|
|
|
|
func init() {
|
|
buildInfo = moduleBuildInfo
|
|
}
|
|
|
|
var buildInfoTmpl = ` mod {{.Main.Path}} {{.Main.Version}} {{.Main.Sum}}
|
|
{{range .Deps}} dep {{.Path}} {{.Version}} {{.Sum}}{{if .Replace}}
|
|
=> {{.Replace.Path}} {{.Replace.Version}} {{.Replace.Sum}}{{end}}
|
|
{{end}}`
|
|
|
|
func moduleBuildInfo() string {
|
|
info, ok := debug.ReadBuildInfo()
|
|
if !ok {
|
|
return "not built in module mode"
|
|
}
|
|
|
|
buf := new(bytes.Buffer)
|
|
err := template.Must(template.New("buildinfo").Parse(buildInfoTmpl)).Execute(buf, info)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return buf.String()
|
|
}
|