1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-04 19:17:37 +08:00

all: run gofmt -w -r 'interface{} -> any'

This commit is contained in:
wdvxdr 2023-01-26 23:03:08 +08:00
parent 84e061f321
commit 20c62111f5
9 changed files with 11 additions and 11 deletions

View File

@ -2083,7 +2083,7 @@ func (bot *CQBot) CQReloadEventFilter(file string) global.MSG {
} }
// OK 生成成功返回值 // OK 生成成功返回值
func OK(data interface{}) global.MSG { func OK(data any) global.MSG {
return global.MSG{"data": data, "retcode": 0, "status": "ok"} return global.MSG{"data": data, "retcode": 0, "status": "ok"}
} }

View File

@ -807,7 +807,7 @@ func (bot *CQBot) ConvertContentMessage(content []global.MSG, sourceType message
// 返回 interface{} 存在三种类型 // 返回 interface{} 存在三种类型
// //
// message.IMessageElement []message.IMessageElement nil // message.IMessageElement []message.IMessageElement nil
func (bot *CQBot) ToElement(t string, d map[string]string, sourceType message.SourceType) (m interface{}, err error) { func (bot *CQBot) ToElement(t string, d map[string]string, sourceType message.SourceType) (m any, err error) {
switch t { switch t {
case "text": case "text":
if base.SplitURL { if base.SplitURL {

View File

@ -21,7 +21,7 @@ import (
) )
// ToFormattedMessage 将给定[]message.IMessageElement转换为通过coolq.SetMessageFormat所定义的消息上报格式 // ToFormattedMessage 将给定[]message.IMessageElement转换为通过coolq.SetMessageFormat所定义的消息上报格式
func ToFormattedMessage(e []message.IMessageElement, source message.Source) (r interface{}) { func ToFormattedMessage(e []message.IMessageElement, source message.Source) (r any) {
if base.PostFormat == "string" { if base.PostFormat == "string" {
r = toStringMessage(e, source) r = toStringMessage(e, source)
} else if base.PostFormat == "array" { } else if base.PostFormat == "array" {

View File

@ -84,7 +84,7 @@ func (r *reader) arrayMsg() []global.MSG {
return msgs return msgs
} }
func (r *reader) obj() interface{} { func (r *reader) obj() any {
switch coder := r.coder(); coder { switch coder := r.coder(); coder {
case coderNil: case coderNil:
return nil return nil

View File

@ -96,7 +96,7 @@ func (w *writer) arrayMsg(a []global.MSG) {
} }
} }
func (w *writer) obj(o interface{}) { func (w *writer) obj(o any) {
switch x := o.(type) { switch x := o.(type) {
case nil: case nil:
w.nil() w.nil()

View File

@ -108,7 +108,7 @@ func (hook *LocalHook) SetPath(path string) {
} }
// NewLocalHook 初始化本地日志钩子实现 // NewLocalHook 初始化本地日志钩子实现
func NewLocalHook(args interface{}, consoleFormatter, fileFormatter logrus.Formatter, levels ...logrus.Level) *LocalHook { func NewLocalHook(args any, consoleFormatter, fileFormatter logrus.Formatter, levels ...logrus.Level) *LocalHook {
hook := &LocalHook{ hook := &LocalHook{
lock: new(sync.Mutex), lock: new(sync.Mutex),
} }

View File

@ -8,7 +8,7 @@ import (
) )
// MSG 消息Map // MSG 消息Map
type MSG = map[string]interface{} type MSG = map[string]any
// VersionNameCompare 检查版本名是否需要更新, 仅适用于 go-cqhttp 的版本命名规则 // VersionNameCompare 检查版本名是否需要更新, 仅适用于 go-cqhttp 的版本命名规则
// //

View File

@ -19,7 +19,7 @@ import (
// type gjson.True or gjson.False // type gjson.True or gjson.False
// //
// type string "true","yes","1" or "false","no","0" (case insensitive) // type string "true","yes","1" or "false","no","0" (case insensitive)
func EnsureBool(p interface{}, defaultVal bool) bool { func EnsureBool(p any, defaultVal bool) bool {
var str string var str string
if b, ok := p.(bool); ok { if b, ok := p.(bool); ok {
return b return b

View File

@ -50,7 +50,7 @@ func longPolling(bot *coolq.CQBot, maxSize int) api.Handler {
return nil return nil
} }
var ( var (
ch = make(chan []interface{}) ch = make(chan []any)
timeout = time.Duration(p.Get("timeout").Int()) * time.Second timeout = time.Duration(p.Get("timeout").Int()) * time.Second
) )
go func() { go func() {
@ -63,7 +63,7 @@ func longPolling(bot *coolq.CQBot, maxSize int) api.Handler {
if limit <= 0 || queue.Len() < limit { if limit <= 0 || queue.Len() < limit {
limit = queue.Len() limit = queue.Len()
} }
ret := make([]interface{}, limit) ret := make([]any, limit)
elem := queue.Front() elem := queue.Front()
for i := 0; i < limit; i++ { for i := 0; i < limit; i++ {
ret[i] = elem.Value ret[i] = elem.Value
@ -81,7 +81,7 @@ func longPolling(bot *coolq.CQBot, maxSize int) api.Handler {
if timeout != 0 { if timeout != 0 {
select { select {
case <-time.After(timeout): case <-time.After(timeout):
return coolq.OK([]interface{}{}) return coolq.OK([]any{})
case ret := <-ch: case ret := <-ch:
return coolq.OK(ret) return coolq.OK(ret)
} }