perf👌: Optimize go warnings

This commit is contained in:
wenjianzhang
2023-08-01 22:38:41 +08:00
parent 69df1b3d34
commit 37a5963cd6
41 changed files with 83 additions and 87 deletions
+2 -2
View File
@@ -44,7 +44,7 @@ type File struct {
func (e File) UploadFile(c *gin.Context) {
e.MakeContext(c)
tag, _ := c.GetPostForm("type")
urlPrefix := fmt.Sprintf("http://%s/", c.Request.Host)
urlPrefix := fmt.Sprintf("%s://%s/", "http", c.Request.Host)
var fileResponse FileResponse
switch tag {
@@ -201,4 +201,4 @@ func ossUpload(name string, path string) error {
func qiniuUpload(name string, path string) error {
oss := file_store.ALiYunOSS{}
return oss.UpLoad(name, path)
}
}
+13 -14
View File
@@ -3,7 +3,6 @@ package apis
import (
"fmt"
"github.com/shirou/gopsutil/v3/net"
"regexp"
"runtime"
"strconv"
"strings"
@@ -27,15 +26,15 @@ const (
)
var (
Version string
expectDiskFsTypes = []string{
"apfs", "ext4", "ext3", "ext2", "f2fs", "reiserfs", "jfs", "btrfs",
"fuseblk", "zfs", "simfs", "ntfs", "fat32", "exfat", "xfs", "fuse.rclone",
}
//Version string
//expectDiskFsTypes = []string{
// "apfs", "ext4", "ext3", "ext2", "f2fs", "reiserfs", "jfs", "btrfs",
// "fuseblk", "zfs", "simfs", "ntfs", "fat32", "exfat", "xfs", "fuse.rclone",
//}
excludeNetInterfaces = []string{
"lo", "tun", "docker", "veth", "br-", "vmbr", "vnet", "kube",
}
getMacDiskNo = regexp.MustCompile(`\/dev\/disk(\d)s.*`)
//getMacDiskNo = regexp.MustCompile(`\/dev\/disk(\d)s.*`)
)
var (
@@ -84,17 +83,17 @@ func (e ServerMonitor) ServerInfo(c *gin.Context) {
osDic["hostName"] = sysInfo.Hostname
osDic["time"] = time.Now().Format("2006-01-02 15:04:05")
mem, _ := mem.VirtualMemory()
memory, _ := mem.VirtualMemory()
memDic := make(map[string]interface{}, 0)
memDic["used"] = mem.Used / MB
memDic["total"] = mem.Total / MB
memDic["used"] = memory.Used / MB
memDic["total"] = memory.Total / MB
fmt.Println("mem", int(mem.Total/mem.Used*100))
memDic["percent"] = pkg.Round(mem.UsedPercent, 2)
fmt.Println("mem", int(memory.Total/memory.Used*100))
memDic["percent"] = pkg.Round(memory.UsedPercent, 2)
swapDic := make(map[string]interface{}, 0)
swapDic["used"] = mem.SwapTotal - mem.SwapFree
swapDic["total"] = mem.SwapTotal
swapDic["used"] = memory.SwapTotal - memory.SwapFree
swapDic["total"] = memory.SwapTotal
cpuDic := make(map[string]interface{}, 0)
cpuDic["cpuInfo"], _ = cpu.Info()
+1 -1
View File
@@ -17,7 +17,7 @@ import (
// @Param pageIndex query int false "pageIndex / 页码"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/db/columns/page [get]
func (e *Gen) GetDBColumnList(c *gin.Context) {
func (e Gen) GetDBColumnList(c *gin.Context) {
e.Context = c
log := e.GetLogger()
var data tools.DBColumns
+1 -1
View File
@@ -19,7 +19,7 @@ import (
// @Param pageIndex query int false "pageIndex / 页码"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/db/tables/page [get]
func (e *Gen) GetDBTableList(c *gin.Context) {
func (e Gen) GetDBTableList(c *gin.Context) {
//var res response.Response
var data tools.DBTables
var err error