Browse Source

version: fix version output for "go run"

Before (note attempted use of absent date and commit hash):

"short": "1.37.0-dev",
"long": "1.37.0-dev-t",

After:

"short": "1.37.0-ERR-BuildInfo",
"long": "1.37.0-ERR-BuildInfo",

Signed-off-by: David Anderson <[email protected]>
David Anderson 3 years ago
parent
commit
b64d900f0f
1 changed files with 5 additions and 0 deletions
  1. 5 0
      version/version.go

+ 5 - 0
version/version.go

@@ -134,6 +134,11 @@ var getEmbeddedInfo = lazy.SyncFunc(func() embeddedInfo {
 			ret.dirty = true
 		}
 	}
+	if ret.commit == "" || ret.commitDate == "" {
+		// Build info is present in the binary, but has no useful data. Act as
+		// if it's missing.
+		return embeddedInfo{}
+	}
 	return ret
 })