version: remove build constraint (#3998)

Remove the go1.18 build constraint, we no longer build on go1.17 or
earlier.
This commit is contained in:
Alessandro Arzilli
2025-04-28 17:45:26 +02:00
committed by GitHub
parent 423b29b5ac
commit 64ac23de8c
2 changed files with 27 additions and 41 deletions

View File

@ -1,39 +0,0 @@
//go:build go1.18
package version
import (
"runtime/debug"
"strings"
)
func init() {
fixBuild = buildInfoFixBuild
}
func buildInfoFixBuild(v *Version) {
// Return if v.Build already set, but not if it is Git ident expand file blob hash
if !strings.HasPrefix(v.Build, "$Id: ") && !strings.HasSuffix(v.Build, " $") {
return
}
info, ok := debug.ReadBuildInfo()
if !ok {
return
}
for _, setting := range info.Settings {
if setting.Key == "vcs.revision" {
v.Build = setting.Value
return
}
}
// If we didn't find vcs.revision, try the old key for backward compatibility
for _, setting := range info.Settings {
if setting.Key == "gitrevision" {
v.Build = setting.Value
return
}
}
}

View File

@ -3,6 +3,8 @@ package version
import (
"fmt"
"runtime"
"runtime/debug"
"strings"
)
// Version represents the current version of Delve.
@ -37,6 +39,29 @@ func BuildInfo() string {
return fmt.Sprintf("%s\n%s", runtime.Version(), buildInfo())
}
var fixBuild = func(v *Version) {
// does nothing
func fixBuild(v *Version) {
// Return if v.Build already set, but not if it is Git ident expand file blob hash
if !strings.HasPrefix(v.Build, "$Id$") {
return
}
info, ok := debug.ReadBuildInfo()
if !ok {
return
}
for _, setting := range info.Settings {
if setting.Key == "vcs.revision" {
v.Build = setting.Value
return
}
}
// If we didn't find vcs.revision, try the old key for backward compatibility
for _, setting := range info.Settings {
if setting.Key == "gitrevision" {
v.Build = setting.Value
return
}
}
}