This commit is contained in:
Gerasimos (Makis) Maropoulos 2022-04-10 01:11:11 +03:00
parent b0ccd579af
commit 193de00426
No known key found for this signature in database
GPG Key ID: 66FCC29BD385FCA6
3 changed files with 27 additions and 19 deletions

View File

@ -16,8 +16,10 @@ import (
var (
// BuildRevision holds the vcs commit id information.
// Available at go version 1.18+
BuildRevision = context.BuildRevision
// BuildTime holds the vcs commit time information.
// Available at go version 1.18+
BuildTime = context.BuildTime
)

View File

@ -19,7 +19,6 @@ import (
"path/filepath"
"reflect"
"regexp"
"runtime/debug"
"sort"
"strconv"
"strings"
@ -48,29 +47,13 @@ import (
var (
// BuildRevision holds the vcs commit id information.
// Available at go version 1.18+
BuildRevision string
// BuildTime holds the vcs commit time information.
// Available at go version 1.18+
BuildTime string
)
func init() {
if info, ok := debug.ReadBuildInfo(); ok {
for _, setting := range info.Settings {
if BuildRevision != "" && BuildTime != "" {
break
}
if setting.Key == "vcs.revision" {
BuildRevision = setting.Value
}
if setting.Key == "vcs.time" {
BuildTime = setting.Key
}
}
}
}
type (
// BodyDecoder is an interface which any struct can implement in order to customize the decode action
// from ReadJSON and ReadXML

23
context/context_go118.go Normal file
View File

@ -0,0 +1,23 @@
//go:build go1.18
package context
import "runtime/debug"
func init() {
if info, ok := debug.ReadBuildInfo(); ok {
for _, setting := range info.Settings {
if BuildRevision != "" && BuildTime != "" {
break
}
if setting.Key == "vcs.revision" {
BuildRevision = setting.Value
}
if setting.Key == "vcs.time" {
BuildTime = setting.Key
}
}
}
}