From b2a5cec4dddd0bc4ece65ece2dd32908c5c2c994 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Thu, 29 Dec 2022 15:21:17 +0100 Subject: 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. --- version.go | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/version.go b/version.go index 97bf83a..22c780b 100644 --- a/version.go +++ b/version.go @@ -4,7 +4,6 @@ import ( "fmt" "runtime" "runtime/debug" - "strconv" "strings" "github.com/rfjakob/gocryptfs/v2/internal/stupidgcm" @@ -61,28 +60,9 @@ func versionFromBuildInfo() { tlog.Debug.Println("versionFromBuildInfo: ReadBuildInfo() failed") 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 - if GitVersion == gitVersionNotSet { + if GitVersion == gitVersionNotSet && info.Main.Version != "(devel)" { GitVersion = info.Main.Version - if GitVersion == "(devel)" && vcsRevision != "" { - GitVersion = fmt.Sprintf("vcs.revision=%s", vcsRevision) - } - if vcsModified { - GitVersion += "-dirty" - } } if GitVersionFuse == gitVersionFuseNotSet { for _, m := range info.Deps { @@ -95,9 +75,4 @@ func versionFromBuildInfo() { } } } - if BuildDate == buildDateNotSet { - if vcsTime != "" { - BuildDate = fmt.Sprintf("vcs.time=%s", vcsTime) - } - } } -- cgit v1.2.3