Przeglądaj źródła

Only get userAgent when needed

hangzws 7 lat temu
rodzic
commit
0470f94ffc
2 zmienionych plików z 4 dodań i 4 usunięć
  1. 2 2
      oss/conf.go
  2. 2 2
      oss/utils.go

+ 2 - 2
oss/conf.go

@@ -44,8 +44,8 @@ func getDefaultOssConfig() *Config {
 	config.AccessKeySecret = ""
 	config.RetryTimes = 5
 	config.IsDebug = false
-	config.UserAgent = userAgent
-	config.Timeout = 60  // Seconds
+	config.UserAgent = userAgent()
+	config.Timeout = 60 // Seconds
 	config.SecurityToken = ""
 	config.IsCname = false
 

+ 2 - 2
oss/utils.go

@@ -16,11 +16,11 @@ import (
 
 // userAgent gets user agent
 // It has the SDK version information, OS information and GO version
-var userAgent = func() string {
+func userAgent() string {
 	sys := getSysInfo()
 	return fmt.Sprintf("aliyun-sdk-go/%s (%s/%s/%s;%s)", Version, sys.name,
 		sys.release, sys.machine, runtime.Version())
-}()
+}
 
 type sysInfo struct {
 	name    string // OS name such as windows/Linux