/
Version.go
56 lines (49 loc) · 1.24 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
52
53
54
55
56
package fitapp
import (
"fmt"
"os"
"runtime"
"time"
)
func ProgramVersion() string {
return "0.7"
}
// Version is a subcommand to output the command name and golang runtime.Version().
func PrintVersion() {
ex, _ := os.Executable()
fi, _ := os.Stat(ex)
fmt.Printf("%s version %s built using %s GOOS %v\n",
os.Args[0],
ProgramVersion(),
runtime.Version(),
runtime.GOOS)
var loc *time.Location
var errl error
if runtime.GOOS == "android" {
// workaround for https://golang.org/src/time/zoneinfo_android.go line 25 hard coded UTC
tz := os.Getenv("TZ")
if os.Getenv("TZ") == "" {
fmt.Println("WARN: TZ is empty or not set")
}
loc, errl = time.LoadLocation(tz)
if errl != nil {
panic(errl)
}
} else {
loc = time.Local
}
fmt.Printf("executable: %v %v %s %s\n",
fi.Mode(),
fi.Size(),
fi.ModTime().In(loc).Format(time.UnixDate),
ex)
//name, offset := time.Now().Local().Zone()
//fmt.Printf("z: %+v %+v\n", name, offset)
//fmt.Printf("tz: %+v\n", os.Getenv("TZ"))
//fmt.Printf("aha: %+v\n", fi.ModTime().In(loc).Format(time.UnixDate))
//x := fi.ModTime()
//x.loc = Local
//fmt.Printf("tz: %+v\n", os.Setenv("TZ", "America/Los_Angeles"))
//time.LoadLocation(time.Local)
//time.LoadLocation("America/Los_Angeles")
}