main: BuildInfo: fix build with Go 1.17 and older
On Go 1.17 and older we get this: Error: ./version.go:67:24: info.Settings undefined (type *debug.BuildInfo has no field or method Settings) Fix the build error by shedding some nice-to-have features.
This commit is contained in:
parent
856ccaac10
commit
b2a5cec4dd
27
version.go
27
version.go
@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/rfjakob/gocryptfs/v2/internal/stupidgcm"
|
"github.com/rfjakob/gocryptfs/v2/internal/stupidgcm"
|
||||||
@ -61,28 +60,9 @@ func versionFromBuildInfo() {
|
|||||||
tlog.Debug.Println("versionFromBuildInfo: ReadBuildInfo() failed")
|
tlog.Debug.Println("versionFromBuildInfo: ReadBuildInfo() failed")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Parse BuildSettings
|
|
||||||
var vcsRevision, vcsTime string
|
|
||||||
var vcsModified bool
|
|
||||||
for _, s := range info.Settings {
|
|
||||||
switch s.Key {
|
|
||||||
case "vcs.revision":
|
|
||||||
vcsRevision = s.Value
|
|
||||||
case "vcs.time":
|
|
||||||
vcsTime = s.Value
|
|
||||||
case "vcs.modified":
|
|
||||||
vcsModified, _ = strconv.ParseBool(s.Value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Fill our version strings
|
// Fill our version strings
|
||||||
if GitVersion == gitVersionNotSet {
|
if GitVersion == gitVersionNotSet && info.Main.Version != "(devel)" {
|
||||||
GitVersion = info.Main.Version
|
GitVersion = info.Main.Version
|
||||||
if GitVersion == "(devel)" && vcsRevision != "" {
|
|
||||||
GitVersion = fmt.Sprintf("vcs.revision=%s", vcsRevision)
|
|
||||||
}
|
|
||||||
if vcsModified {
|
|
||||||
GitVersion += "-dirty"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if GitVersionFuse == gitVersionFuseNotSet {
|
if GitVersionFuse == gitVersionFuseNotSet {
|
||||||
for _, m := range info.Deps {
|
for _, m := range info.Deps {
|
||||||
@ -95,9 +75,4 @@ func versionFromBuildInfo() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if BuildDate == buildDateNotSet {
|
|
||||||
if vcsTime != "" {
|
|
||||||
BuildDate = fmt.Sprintf("vcs.time=%s", vcsTime)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user