Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Commit

Permalink
add buildinfo package to hold ldflags info
Browse files Browse the repository at this point in the history
  • Loading branch information
martinnirtl committed Feb 27, 2020
1 parent b4db778 commit 79afd53
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions internal/buildinfo/buildinfo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package buildinfo

import (
"fmt"
"time"
)

// VersionInfo describes structure of version information objects.
type VersionInfo struct {
Version string
Commit string
Date string
}

var (
version = "development"
commit = "na"
date = time.Now().Local().Format(time.ANSIC)

// Version provides access to version info and related printing functions.
Version *VersionInfo
)

func init() {
Version = &VersionInfo{
Version: version,
Commit: commit,
Date: date,
}
}

// Print prints the version information.
func (v *VersionInfo) Print() {
fmt.Printf("Dockma CLI version %s\n", v.Version)
}

// PrintFull prints the full version information including built date and last commit.
func (v *VersionInfo) PrintFull() {
fmt.Printf("Dockma CLI Version %s built on %s (commit: %s)\n", v.Version, v.Date, v.Commit)
}

0 comments on commit 79afd53

Please sign in to comment.