Skip to content

Commit

Permalink
Set built by diagnostic information when go modules are used
Browse files Browse the repository at this point in the history
  • Loading branch information
jbowes committed Aug 8, 2021
1 parent 80a366f commit a9418d6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions internal/diagnostics/diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ var (
builtBy = "unknown"
)

func getVersion() string {
func loadBuildInfo() {
// If the version was previously set here, or set with -ldflags -X, leave it be.
if version != "(devel)" {
return version
return
}

// See if we can get a version from module build info.
Expand All @@ -34,10 +34,10 @@ func getVersion() string {

if version == "(devel)" {
version = "unknown"
} else if builtBy == "unknown" {
builtBy = "go module"
}
}

return version
}

type Diagnostics struct {
Expand All @@ -55,8 +55,10 @@ type Diagnostics struct {
}

func New() *Diagnostics {
loadBuildInfo()

return &Diagnostics{
Version: getVersion(),
Version: version,
BuildTime: buildTime,
BuiltBy: builtBy,

Expand Down

0 comments on commit a9418d6

Please # to comment.