@@ -24,27 +24,37 @@ func ConstructHTTPHeaders(appToken string) http.Header {
2424 return headers
2525}
2626
27+ var customUserAgent string
28+
29+ func SetUserAgent (ua string ) {
30+ customUserAgent = ua
31+ }
32+
2733func GetUserAgent () string {
28- details := []string {}
34+ if customUserAgent != "" {
35+ return customUserAgent
36+ }
2937
30- cliVersion := "phase-golang-sdk/" + misc .Version
31- details = append (details , cliVersion )
38+ details := []string {}
3239
33- osType := runtime .GOOS
34- architecture := runtime .GOARCH
35- details = append (details , fmt .Sprintf ("%s %s" , osType , architecture ))
40+ cliVersion := "phase-golang-sdk/" + misc .Version
41+ details = append (details , cliVersion )
3642
37- currentUser , err := user .Current ()
38- if err == nil {
39- hostname , err := os .Hostname ()
40- if err == nil {
41- userHostString := fmt .Sprintf ("%s@%s" , currentUser .Username , hostname )
42- details = append (details , userHostString )
43- }
44- }
43+ osType := runtime .GOOS
44+ architecture := runtime .GOARCH
45+ details = append (details , fmt .Sprintf ("%s %s" , osType , architecture ))
46+
47+ currentUser , err := user .Current ()
48+ if err == nil {
49+ hostname , err := os .Hostname ()
50+ if err == nil {
51+ userHostString := fmt .Sprintf ("%s@%s" , currentUser .Username , hostname )
52+ details = append (details , userHostString )
53+ }
54+ }
4555
4656 // Return only the concatenated string without "User-Agent:" prefix
47- return strings .Join (details , " " )
57+ return strings .Join (details , " " )
4858}
4959
5060func createHTTPClient () * http.Client {
0 commit comments