forked from 0xERR0R/blocky
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_static.go
43 lines (33 loc) · 804 Bytes
/
main_static.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
//go:build linux
// +build linux
package main
import (
"os"
"time"
_ "time/tzdata"
_ "github.com/breml/rootcerts"
reaper "github.com/ramr/go-reaper"
)
//nolint:gochecknoinits
func init() {
go reaper.Reap()
setLocaltime()
}
// set localtime to /etc/localtime if available
// or modify the system time with the TZ environment variable if it is provided
func setLocaltime() {
// load /etc/localtime without modifying it
if lt, err := os.ReadFile("/etc/localtime"); err == nil {
if t, err := time.LoadLocationFromTZData("", lt); err == nil {
time.Local = t
return
}
}
// use zoneinfo from time/tzdata and set location with the TZ environment variable
if tz := os.Getenv("TZ"); tz != "" {
if t, err := time.LoadLocation(tz); err == nil {
time.Local = t
return
}
}
}