diff --git a/control/web/gui.go b/control/web/gui.go index 0cbc8b6c..71a509d7 100644 --- a/control/web/gui.go +++ b/control/web/gui.go @@ -1,7 +1,4 @@ -// Package webctrl -/* - * 一个用户webui的包,里面包含了webui所需的所有内容 - */ +// Package webctrl 包含 webui 所需的所有内容 package webctrl import ( diff --git a/utils/file/dir_nowin.go b/utils/file/dir_nowin.go index a4523c40..d848641e 100644 --- a/utils/file/dir_nowin.go +++ b/utils/file/dir_nowin.go @@ -5,6 +5,7 @@ package file import "os" +// Pwd 获取当前路径 func Pwd() (path string) { path, _ = os.Getwd() return diff --git a/utils/file/dir_win.go b/utils/file/dir_win.go index a1dd4708..02565854 100644 --- a/utils/file/dir_win.go +++ b/utils/file/dir_win.go @@ -8,6 +8,7 @@ import ( "strings" ) +// Pwd 获取当前路径的正斜杠表示 func Pwd() string { path, _ := os.Getwd() return strings.ReplaceAll(path, "\\", "/") diff --git a/utils/file/f.go b/utils/file/f.go index c38b0069..9673b812 100644 --- a/utils/file/f.go +++ b/utils/file/f.go @@ -2,6 +2,7 @@ package file import "os" +// BOT_PATH BOT当前路径 var BOT_PATH = Pwd() // IsExist 文件/路径存在 @@ -10,7 +11,7 @@ func IsExist(path string) bool { return err == nil || os.IsExist(err) } -// IsExist 文件/路径不存在 +// IsNotExist 文件/路径不存在 func IsNotExist(path string) bool { _, err := os.Stat(path) return err != nil && os.IsNotExist(err) diff --git a/utils/file/updater.go b/utils/file/updater.go index a26c60c5..7f8c87d1 100644 --- a/utils/file/updater.go +++ b/utils/file/updater.go @@ -82,7 +82,7 @@ func GetLazyData(path string, isReturnDataBytes, isDataMustEqual bool) ([]byte, if err != nil { return nil, err } - if len(data) <= 0 { + if len(data) == 0 { return nil, errors.New("read body len <= 0") } if filemd5 != nil { diff --git a/utils/process/sleep.go b/utils/process/sleep.go index a67d8d89..541ae082 100644 --- a/utils/process/sleep.go +++ b/utils/process/sleep.go @@ -1,3 +1,4 @@ +// Package process 流程控制相关 package process import ( @@ -5,6 +6,7 @@ import ( "time" ) +// SleepAbout1sTo2s 随机阻塞等待 1 ~ 2s func SleepAbout1sTo2s() { time.Sleep(time.Second + time.Millisecond*time.Duration(rand.Intn(1000))) } diff --git a/utils/web/http.go b/utils/web/http.go index 57e26084..23c5c21c 100644 --- a/utils/web/http.go +++ b/utils/web/http.go @@ -1,3 +1,4 @@ +// Package web 网络处理相关 package web import ( @@ -6,6 +7,7 @@ import ( "net/http" ) +// ReqWith 使用自定义请求头获取数据 func ReqWith(url string, method string, referer string, ua string) (data []byte, err error) { client := &http.Client{} // 提交请求 @@ -25,6 +27,7 @@ func ReqWith(url string, method string, referer string, ua string) (data []byte, return } +// GetData 获取数据 func GetData(url string) (data []byte, err error) { var response *http.Response response, err = http.Get(url)