From 0315631b5389ecd6725b37a090c28e7670855e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=A0=E5=88=AB?= <62596032+Tiper-In-Github@users.noreply.github.com> Date: Sun, 29 Sep 2024 15:32:36 +0800 Subject: [PATCH] Fix:err is never used Fix the problem that err is overwritten and becomes invalid --- app/other/apis/sys_server_monitor.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/other/apis/sys_server_monitor.go b/app/other/apis/sys_server_monitor.go index c9aee1d6..9423d9cd 100644 --- a/app/other/apis/sys_server_monitor.go +++ b/app/other/apis/sys_server_monitor.go @@ -49,9 +49,9 @@ type ServerMonitor struct { // GetHourDiffer 获取相差时间 func GetHourDiffer(startTime, endTime string) int64 { var hour int64 - t1, err := time.ParseInLocation("2006-01-02 15:04:05", startTime, time.Local) - t2, err := time.ParseInLocation("2006-01-02 15:04:05", endTime, time.Local) - if err == nil && t1.Before(t2) { + t1, err1 := time.ParseInLocation("2006-01-02 15:04:05", startTime, time.Local) + t2, err2 := time.ParseInLocation("2006-01-02 15:04:05", endTime, time.Local) + if err1 == nil && err2 == nil && t1.Before(t2) { diff := t2.Unix() - t1.Unix() // hour = diff / 3600 return hour @@ -70,7 +70,7 @@ func GetHourDiffer(startTime, endTime string) int64 { func (e ServerMonitor) ServerInfo(c *gin.Context) { e.Context = c - sysInfo, err := host.Info() + sysInfo, _ := host.Info() osDic := make(map[string]interface{}, 0) osDic["goOs"] = runtime.GOOS osDic["arch"] = runtime.GOARCH