-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.go
51 lines (42 loc) · 1.08 KB
/
version.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
51
/*
File: version.go
Author: YJ
Email: yj1516268@outlook.com
Created Time: 2024-06-30 11:08:32
Description: 版本信息
*/
package general
import (
"strconv"
"time"
)
const (
Name string = "Wocker" // 程序名
Version string = "v0.0.1" // 程序版本
Project string = "github.com/yhyj/wocker" // 项目地址
)
var (
GitCommitHash string = "Unknown" // Git 提交 Hash
BuildTime string = "Unknown" // 编译时间
BuildBy string = "Unknown" // 编译者
)
// ProgramInfo 返回程序信息
//
// 返回:
// - 程序信息
func ProgramInfo() map[string]string {
programInfo := make(map[string]string)
// 解析构建时间
BuildTimeConverted := "Unknown"
timestamp, err := strconv.ParseInt(BuildTime, 10, 64)
if err == nil {
BuildTimeConverted = time.Unix(timestamp, 0).String()
}
programInfo["Name"] = Name
programInfo["Version"] = Version
programInfo["Project"] = Project
programInfo["GitCommitHash"] = GitCommitHash
programInfo["BuildTime"] = BuildTimeConverted
programInfo["BuildBy"] = BuildBy
return programInfo
}