Files
athens/pkg/build/build.go
Nicholas Wiersma d932d50232 chore: lint code with golangci-lint (#1828)
* feat: add golangci-lint linting

* chore: fix linter issues

* feat: add linting into the workflow

* docs: update lint docs

* fix: cr suggestions

* fix: remove old formatting and vetting scripts

* fix: add docker make target

* fix: action go caching

* fix: depreciated actions checkout version

* fix: cr suggestion

* fix: cr suggestions

---------

Co-authored-by: Manu Gupta <manugupt1@gmail.com>
2023-02-24 20:39:17 -08:00

39 lines
1001 B
Go

// Package build provides details of the built binary
// The details are set using ldflags.
//
// The ldflags can be set manually for testing locally:
// `go build -ldflags "-X github.com/gomods/athens/pkg/build.version=$(git describe --tags) -X github.com/gomods/athens/pkg/build.buildDate=$(date -u +%Y-%m-%d-%H:%M:%S-%Z)"`
package build
import (
"fmt"
)
// Details represents known data for a given build.
type Details struct {
Version string `json:"version,omitempty"`
Date string `json:"date,omitempty"`
}
var version, buildDate string
// String returns build details as a string with formatting
// suitable for console output.
//
// i.e.
// Build Details:
//
// Version: v0.1.0-155-g1a20f8b
// Date: 2018-11-05-14:33:14-UTC
func String() string {
return fmt.Sprintf("Build Details:\n\tVersion:\t%s\n\tDate:\t\t%s", version, buildDate)
}
// Data returns build details as a struct.
func Data() Details {
return Details{
Version: version,
Date: buildDate,
}
}