From 0ff9f0fc4b0e541977b5f25aaab5900425aad724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Tue, 17 May 2022 20:39:17 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BC=98=E5=8C=96=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api.go | 4 ++-- app.go | 7 ++----- client.go | 7 ++----- gin.go | 4 ++-- system_test.go | 4 +--- version.go | 2 +- 6 files changed, 10 insertions(+), 18 deletions(-) diff --git a/api.go b/api.go index ea6267d..e8b2d1d 100644 --- a/api.go +++ b/api.go @@ -11,7 +11,7 @@ type api struct { tableName string // 日志表名 insideIp string // 内网ip hostname string // 主机名 - goVersion float64 // go版本 + goVersion string // go版本 } // ApiPostgresqlLog 结构体 @@ -31,7 +31,7 @@ type ApiPostgresqlLog struct { ResponseTime TimeString `gorm:"index" json:"response_time"` //【返回】时间 SystemHostName string `gorm:"type:text" json:"system_host_name"` //【系统】主机名 SystemInsideIp string `gorm:"type:text" json:"system_inside_ip"` //【系统】内网ip - GoVersion float64 `gorm:"type:bigint" json:"go_version"` //【程序】Go版本 + GoVersion string `gorm:"type:text" json:"go_version"` //【程序】Go版本 } // AutoMigrate 自动迁移 diff --git a/app.go b/app.go index cf86fd1..de5fe25 100644 --- a/app.go +++ b/app.go @@ -5,7 +5,6 @@ import ( "gorm.io/gorm" "os" "runtime" - "strconv" "strings" ) @@ -28,8 +27,7 @@ func (a *App) InitClientApi() { a.Api.tableName = a.TableName a.Api.hostname, _ = os.Hostname() a.Api.insideIp = goip.GetInsideIp() - goVersion, _ := strconv.ParseFloat(strings.TrimPrefix(runtime.Version(), "go"), 64) - a.Api.goVersion = goVersion + a.Api.goVersion = strings.TrimPrefix(runtime.Version(), "go") a.Api.AutoMigrate() } @@ -45,7 +43,6 @@ func (a *App) InitClientGin() { a.Gin.tableName = a.TableName a.Gin.hostname, _ = os.Hostname() a.Gin.insideIp = goip.GetInsideIp() - goVersion, _ := strconv.ParseFloat(strings.TrimPrefix(runtime.Version(), "go"), 64) - a.Gin.goVersion = goVersion + a.Gin.goVersion = strings.TrimPrefix(runtime.Version(), "go") a.Gin.AutoMigrate() } diff --git a/client.go b/client.go index 0abb7da..466f2b1 100644 --- a/client.go +++ b/client.go @@ -5,7 +5,6 @@ import ( "gorm.io/gorm" "os" "runtime" - "strconv" "strings" ) @@ -23,8 +22,7 @@ func NewClientGin(db *gorm.DB, tableName string) *Client { panic("表名不能为空") } hostname, _ := os.Hostname() - goVersion, _ := strconv.ParseFloat(strings.TrimPrefix(runtime.Version(), "go"), 64) - client := &Client{Gin: gin{db: db, tableName: tableName, hostname: hostname, insideIp: goip.GetInsideIp(), goVersion: goVersion}} + client := &Client{Gin: gin{db: db, tableName: tableName, hostname: hostname, insideIp: goip.GetInsideIp(), goVersion: strings.TrimPrefix(runtime.Version(), "go")}} client.Gin.AutoMigrate() return client } @@ -38,8 +36,7 @@ func NewClientApi(db *gorm.DB, tableName string) *Client { panic("表名不能为空") } hostname, _ := os.Hostname() - goVersion, _ := strconv.ParseFloat(strings.TrimPrefix(runtime.Version(), "go"), 64) - client := &Client{Api: api{db: db, tableName: tableName, hostname: hostname, insideIp: goip.GetInsideIp(), goVersion: goVersion}} + client := &Client{Api: api{db: db, tableName: tableName, hostname: hostname, insideIp: goip.GetInsideIp(), goVersion: strings.TrimPrefix(runtime.Version(), "go")}} client.Api.AutoMigrate() return client } diff --git a/gin.go b/gin.go index 95103d5..e221cbc 100644 --- a/gin.go +++ b/gin.go @@ -11,7 +11,7 @@ type gin struct { tableName string // 日志表名 insideIp string // 内网ip hostname string // 主机名 - goVersion float64 // go版本 + goVersion string // go版本 } // GinPostgresqlLog 结构体 @@ -42,7 +42,7 @@ type GinPostgresqlLog struct { CostTime int64 `gorm:"type:bigint" json:"cost_time"` //【系统】花费时间 SystemHostName string `gorm:"type:text" json:"system_host_name"` //【系统】主机名 SystemInsideIp string `gorm:"type:text" json:"system_inside_ip"` //【系统】内网ip - GoVersion float64 `gorm:"type:bigint" json:"go_version"` //【程序】Go版本 + GoVersion string `gorm:"type:bigint" json:"go_version"` //【程序】Go版本 } // AutoMigrate 自动迁移 diff --git a/system_test.go b/system_test.go index aacd02d..674b7a3 100644 --- a/system_test.go +++ b/system_test.go @@ -2,7 +2,6 @@ package golog import ( "runtime" - "strconv" "strings" "testing" ) @@ -12,6 +11,5 @@ func TestSystem(t *testing.T) { s.Init() t.Logf("%+v", s) t.Logf("%+v", runtime.Version()) - goVersion, _ := strconv.ParseFloat(strings.TrimPrefix(runtime.Version(), "go"), 64) - t.Logf("%+v", goVersion) + t.Logf("%+v", strings.TrimPrefix(runtime.Version(), "go")) } diff --git a/version.go b/version.go index 3044e66..88054fd 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package golog -const Version = "1.0.8" +const Version = "1.0.9"