Skip to content
This repository was archived by the owner on Sep 7, 2024. It is now read-only.

chore: improving version.go file #77

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
)

// These constants follow the semantic versioning 2.0.0 spec (http://semver.org/)
type Version struct {
Meta string `json:"meta" xml:"meta"`
Major uint8 `json:"major" xml:"major"`
Expand All @@ -14,18 +15,24 @@ type Version struct {
}

var version = Version{
Meta: "beta",
Major: 0,
Minor: 1,
Patch: 0,
Meta: "beta",
}

func Agent() string {
return fmt.Sprintf("timetrace %s", StringVersion())
return fmt.Sprintf("timetrace/%s", StringVersion())
}

func StringVersion() string {
return fmt.Sprintf("%d.%d.%d-%s", version.Major, version.Minor, version.Patch, version.Meta)
v := fmt.Sprintf("%d.%d.%d", version.Major, version.Minor, version.Patch)

if version.Meta != "" {
v = fmt.Sprintf("%s-%s", v, version.Meta)
}

return v
}

func JSONVersion() (string, error) {
Expand Down