-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
26 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,33 @@ | ||
package core | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
) | ||
|
||
func Version() string { | ||
// NOTE: equivalent "go get" version in format x.y.z is 1.x.y (z not used) (ex: 3.3.0 -> 1.3.3). This is done because go doesn't seem to allow having versions bigger then 1 without altering the import paths. | ||
|
||
v := "3.3.0" | ||
return taggedVersion(v) | ||
return timedVersion(v, true) | ||
} | ||
|
||
func taggedVersion(v string) string { | ||
func timedVersion(v string, release bool) string { | ||
t := versionTime() | ||
if !release { | ||
tag := t.Format("200601021504") | ||
return fmt.Sprintf("%s-rc.%s", v, tag) // release-candidate format | ||
//return fmt.Sprintf("%s+%s", tag) // build-metadata format (ignored to determine version precedence) | ||
} | ||
return fmt.Sprintf("%s (%s)", v, t.Format("2006/01/02 15:04")) | ||
} | ||
func versionTime() time.Time { | ||
// auto-updated with "go generate" from main directory | ||
date := "#___202206112203___#" | ||
date := "#___202206131603___#" | ||
tag := date[4 : len(date)-4] | ||
|
||
return v + "-rc." + tag // release candidate format | ||
//return v + "+" + tag // build metadata format (ignored to determine version precedence) | ||
layout := "200601021504" | ||
t, err := time.Parse(layout, tag) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return t | ||
} |