-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion.go
More file actions
44 lines (37 loc) · 995 Bytes
/
version.go
File metadata and controls
44 lines (37 loc) · 995 Bytes
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
package main
import (
"KKCardModCheck/config"
"fmt"
"github.com/tcnksm/go-latest"
)
// Additional build metadata injected via -ldflags. Defaults provided for local/dev builds.
var (
version = "0.1.10"
buildDate = "unknown"
gitHash = "unknown"
mod = "debug"
version_res *latest.CheckResponse
version_err error
)
var githubTag = &latest.GithubTag{
Owner: "GenesisAN",
Repository: "KKCardModCheck",
}
func init() {
// 如果通过 ldflags 注入了 version,则把它赋给 APP_VERSION 供界面使用
fmt.Println("Version:", version)
fmt.Println("Build Date:", buildDate)
fmt.Println("Git Hash:", gitHash)
fmt.Println("Module Mode:", mod)
// reference build metadata variables so they are not reported as unused
_ = buildDate
_ = gitHash
_ = mod
// 修复:避免使用 := 导致局部变量遮蔽包级别的 version_res
go func() {
res, err := latest.Check(githubTag, version)
version_res = res
version_err = err
}()
config.Load()
}