-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (36 loc) · 911 Bytes
/
main.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
package main
import (
"fmt"
"os"
"runtime/pprof"
"time"
"github.com/supudo/Kuplung-Go/app"
"github.com/supudo/Kuplung-Go/settings"
)
var version string
func main() {
mbv := time.Now().Format("2019-11-20")
var kapp app.KuplungApp
if len(version) > 0 {
kapp.Version = version
} else {
kapp.Version = fmt.Sprintf("(manual build %v)", mbv)
}
deferrer := make(chan func(), 100)
versionInfo := "Kuplung-Go " + kapp.Version
profileFin, err := initProfiling(mbv)
if err != nil {
settings.LogError("[main] Failed to start CPU profiling: %v\n", err)
}
defer profileFin()
app.Run(kapp.InitializeKuplungWindow, versionInfo, deferrer)
}
func initProfiling(mbv string) (func(), error) {
filename := "Kuplung_CPUProfile_" + mbv + ".log"
f, err := os.Create(filename)
if err != nil {
return func() {}, err
}
err = pprof.StartCPUProfile(f)
return func() { pprof.StopCPUProfile() }, err
}