56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package globals
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// Appname is the application name, populated from main().
|
|
var Appname string = "vaultik"
|
|
|
|
// Version is the application version, populated from main().
|
|
var Version string = "dev"
|
|
|
|
// Commit is the git commit hash, populated from main().
|
|
var Commit string = "unknown"
|
|
|
|
// CommitDate is the ISO-8601 date of the commit, populated from main().
|
|
var CommitDate string = "unknown"
|
|
|
|
// Author identifies the upstream author of vaultik.
|
|
const Author = "Jeffrey Paul <sneak@sneak.berlin>"
|
|
|
|
// Homepage is the canonical URL for vaultik.
|
|
const Homepage = "https://sneak.berlin/go/vaultik"
|
|
|
|
// License is the SPDX identifier for the project license.
|
|
const License = "MIT"
|
|
|
|
// Globals contains application-wide configuration and metadata.
|
|
type Globals struct {
|
|
Appname string
|
|
Version string
|
|
Commit string
|
|
CommitDate string
|
|
StartTime time.Time
|
|
}
|
|
|
|
// New creates and returns a new Globals instance initialized with the package-level variables.
|
|
func New() (*Globals, error) {
|
|
return &Globals{
|
|
Appname: Appname,
|
|
Version: Version,
|
|
Commit: Commit,
|
|
CommitDate: CommitDate,
|
|
}, nil
|
|
}
|
|
|
|
// ShortCommit returns the first 12 chars of the commit hash, or the
|
|
// whole string if it's shorter (e.g. "unknown").
|
|
func (g *Globals) ShortCommit() string {
|
|
if len(g.Commit) > 12 {
|
|
return g.Commit[:12]
|
|
}
|
|
|
|
return g.Commit
|
|
}
|