delve/pkg/version/fixbuild.go
Alessandro Arzilli f34a1e6a5e
version: fix build version using buildInfo (#2789)
In go1.18 buildInfo will include the git revision hash, use that to fix
the Build field of Version so that it is correct even if Delve wasn't
built using make.go.
2021-11-24 13:45:28 -08:00

24 lines
349 B
Go

//go:build go1.18
// +build go1.18
package version
import "runtime/debug"
func init() {
fixBuild = buildInfoFixBuild
}
func buildInfoFixBuild(v *Version) {
info, ok := debug.ReadBuildInfo()
if !ok {
return
}
for i := range info.Settings {
if info.Settings[i].Key == "gitrevision" {
v.Build = info.Settings[i].Value
break
}
}
}