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",
@@ -134,6 +134,11 @@ func (i embeddedInfo) commitAbbrev() string {
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
})
