diff --git a/.gitignore b/.gitignore index 4b43257..fffc7ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ vendor/ .idea +.vscode config.hjson device.json -codec/ data/ logs/ \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml index 553c890..ad35c7e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -55,7 +55,7 @@ linters: - prealloc - predeclared - asciicheck - - revive + - golint - forbidigo - makezero #- interfacer @@ -82,7 +82,7 @@ run: # output configuration options output: - format: 'colored-line-number' + format: "colored-line-number" print-issued-lines: true print-linter-name: true uniq-by-line: true @@ -90,3 +90,6 @@ output: issues: # Fix found issues (if it's supported by the linter) fix: true + exclude-use-default: false + exclude: + - "Error return value of .((os.)?std(out|err)..*|.*Close|.*Flush|os.Remove(All)?|.*print(f|ln)?|os.(Un)?Setenv). is not check" diff --git a/global/config.go b/global/config.go index f75ed0b..f83abab 100644 --- a/global/config.go +++ b/global/config.go @@ -1,5 +1,6 @@ package global +// AccountToken 存储AccountToken供登录使用 var AccountToken []byte // PasswordHash 存储QQ密码哈希供登录使用 diff --git a/global/config/config.go b/global/config/config.go index cb94e11..c1b751a 100644 --- a/global/config/config.go +++ b/global/config/config.go @@ -1,3 +1,4 @@ +// Package config 包含go-cqhttp操作配置文件的相关函数 package config import ( @@ -56,6 +57,7 @@ type Config struct { Database map[string]yaml.Node `yaml:"database"` } +// MiddleWares 通信中间件 type MiddleWares struct { AccessToken string `yaml:"access-token"` Filter string `yaml:"filter"` diff --git a/global/terminal/doc.go b/global/terminal/doc.go new file mode 100644 index 0000000..55212d9 --- /dev/null +++ b/global/terminal/doc.go @@ -0,0 +1,2 @@ +// Package terminal 包含用于检测在windows下是否通过双击运行go-cqhttp的函数 +package terminal diff --git a/global/terminal/double_click.go b/global/terminal/double_click.go index bc0d06a..54bcd1a 100644 --- a/global/terminal/double_click.go +++ b/global/terminal/double_click.go @@ -2,6 +2,7 @@ package terminal +// RunningByDoubleClick 检查是否通过双击直接运行,非Windows系统永远返回false func RunningByDoubleClick() bool { return false } diff --git a/global/update/update.go b/global/update/update.go index 8acd24e..f7ca0c3 100644 --- a/global/update/update.go +++ b/global/update/update.go @@ -1,3 +1,4 @@ +// Package update 包含go-cqhttp自我更新相关函数 package update import ( @@ -34,8 +35,8 @@ func (wc *WriteCounter) PrintProgress() { fmt.Printf("\rDownloading... %s complete", humanize.Bytes(wc.Total)) } -// UpdateFromStream copy form getlantern/go-update -func UpdateFromStream(updateWith io.Reader) (err error, errRecover error) { +// FromStream copy form getlantern/go-update +func FromStream(updateWith io.Reader) (err error, errRecover error) { updatePath, err := osext.Executable() if err != nil { return diff --git a/global/update/update_others.go b/global/update/update_others.go index 7a93296..7326497 100644 --- a/global/update/update_others.go +++ b/global/update/update_others.go @@ -13,6 +13,7 @@ import ( log "github.com/sirupsen/logrus" ) +// Update go-cqhttp自我更新 func Update(url string) { resp, err := http.Get(url) if err != nil { @@ -38,7 +39,7 @@ func Update(url string) { return } if header.Name == "go-cqhttp" { - err, _ := UpdateFromStream(tr) + err, _ := FromStream(tr) fmt.Println() if err != nil { log.Error("更新失败!", err) diff --git a/global/update/update_windows.go b/global/update/update_windows.go index 1414b1a..0570522 100644 --- a/global/update/update_windows.go +++ b/global/update/update_windows.go @@ -10,6 +10,7 @@ import ( log "github.com/sirupsen/logrus" ) +// Update go-cqhttp自我更新 func Update(url string) { resp, err := http.Get(url) if err != nil { @@ -25,7 +26,7 @@ func Update(url string) { log.Error("更新失败!", err) return } - err, _ = UpdateFromStream(file) + err, _ = FromStream(file) fmt.Println() if err != nil { log.Error("更新失败!", err) diff --git a/server/api.go b/server/api.go index 0265520..05fdc77 100644 --- a/server/api.go +++ b/server/api.go @@ -322,6 +322,7 @@ func handleQuickOperation(bot *coolq.CQBot, p resultGetter) coolq.MSG { return bot.CQHandleQuickOperation(p.Get("context"), p.Get("operation")) } +// API 是go-cqhttp当前支持的所有api的映射表 var API = map[string]func(*coolq.CQBot, resultGetter) coolq.MSG{ "get_login_info": getLoginInfo, "get_friend_list": getFriendList, diff --git a/server/http.go b/server/http.go index be1359d..fb23e21 100644 --- a/server/http.go +++ b/server/http.go @@ -43,6 +43,7 @@ type httpContext struct { ctx *gin.Context } +// RunHTTPServerAndClients 启动HTTP服务器与HTTP上报客户端 func RunHTTPServerAndClients(bot *coolq.CQBot, conf *config.HTTPServer) { if conf.Disabled { return