-
Notifications
You must be signed in to change notification settings - Fork 0
/
uymas.go
50 lines (46 loc) · 1.59 KB
/
uymas.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Package uymas is summary util library from the work experience,
// provides base version, author information and so on.
//
// Major functional like `bin` (CLI-APP), `str`(string util), other more. Some of originated from work experience
// to enhance code reuse.
// The final directory is a convenient tool to realize command-line program development and other code.
package uymas
// @Date: 2018/10/30 0030 12:58
// @Author: Joshua Conero
const (
Version = "2.0.0-rc.4" //dev is not product but development tag.
Release = "20241224" // dev|20060102
Since = "20181030"
Author = "Joshua Conero"
Email = "conero@163.com"
Name = "uymas"
PkgName = "conero/uymas"
TimeLayoutDate = "20060102" // date layout-20060102
)
var (
gitHash string
buildData string
buildAuthor string
)
// GetBuildInfo Get the relevant version information after injection with the -ldflags parameters gitHash, buildData, buildAuthor.
//
// shell like:
//
// $gitHash = $(git rev-parse --short HEAD); $buildData = $(get-date -Format 'yyyy-MM-dd');$buildAuthor = 'Joshua Conero';
//
// go build -ldflags "-s -w -X 'gitee.com/conero/uymas/v2.gitHash=$gitHash' -X 'gitee.com/conero/uymas/v2.buildData=$buildData' -X 'gitee.com/conero/uymas/v2.buildAuthor=$buildAuthor'" ./cmd/...
//
// Output format such as: "(buildData gitHash)"
func GetBuildInfo() string {
info := ""
if gitHash != "" && buildData != "" {
info = "(" + buildData + " " + gitHash + ")"
}
if buildAuthor != "" {
if info != "" {
info += " "
}
info += "Power by " + buildAuthor
}
return info
}