forked from kryptco/kr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalytics_ua_darwin.go
More file actions
32 lines (26 loc) · 820 Bytes
/
analytics_ua_darwin.go
File metadata and controls
32 lines (26 loc) · 820 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
package kr
import (
"fmt"
"os/exec"
"strings"
"sync"
)
var analytics_user_agent = fmt.Sprintf("Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/602.2.14 (KHTML, like Gecko) Version/%s kr/%s", CURRENT_VERSION, CURRENT_VERSION)
const analytics_os = "OS X"
var cachedAnalyticsOSVersion *string
var osVersionMutex sync.Mutex
func getAnalyticsOSVersion() *string {
osVersionMutex.Lock()
defer osVersionMutex.Unlock()
if cachedAnalyticsOSVersion != nil {
return cachedAnalyticsOSVersion
}
analytics_os_version_bytes, err := exec.Command("sw_vers", "-productVersion").Output()
if err != nil {
log.Error("error retrieving OS version:", err.Error())
return nil
}
stripped := strings.TrimSpace(string(analytics_os_version_bytes))
cachedAnalyticsOSVersion = &stripped
return cachedAnalyticsOSVersion
}