Skip to content

Commit 7d9e1c1

Browse files
author
Roberto Sora
committed
add global variables and Info struct in order to inject build time values via ldflags
1 parent db4c149 commit 7d9e1c1

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

global/global.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package global
2+
3+
import (
4+
"os"
5+
"path/filepath"
6+
)
7+
8+
// appName is the command line name of the Arduino CLI executable on the user system (users may change it)
9+
var appName = filepath.Base(os.Args[0])
10+
11+
var (
12+
application= "arduino-cli"
13+
version = "missing"
14+
commit = "missing"
15+
cvsRef = "missing"
16+
buildDate = "missing"
17+
repository = "missing"
18+
)
19+
20+
21+
func GetAppName() string {
22+
return appName
23+
}
24+
25+
func GetApplication() string {
26+
return application
27+
}
28+
29+
func GetVersion() string {
30+
return version
31+
}
32+
33+
func GetCommit() string {
34+
return commit
35+
}
36+
37+
func GetCvsRef() string {
38+
return cvsRef
39+
}
40+
41+
func GetBuildDate() string {
42+
return buildDate
43+
}
44+
45+
func GetRepository() string {
46+
return repository
47+
}
48+
49+
type Info struct {
50+
Application string `json:"application"`
51+
Version string `json:"version"`
52+
Commit string `json:"commit"`
53+
CvsRef string `json:"cvsRef"`
54+
BuildDate string `json:"buildDate"`
55+
Repository string `json:"repository"`
56+
}
57+

0 commit comments

Comments
 (0)