From 7dbda5cec7c9a48d4484f2046adbdca625740cf8 Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Wed, 25 May 2022 15:31:26 +0800 Subject: [PATCH] coolq: make linter happy --- coolq/cqcode.go | 2 ++ coolq/cqcode/element.go | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/coolq/cqcode.go b/coolq/cqcode.go index d97c63d..8d9de1d 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -93,6 +93,8 @@ func replyID(r *message.ReplyElement, source message.Source) int32 { } // toElements 将消息元素数组转为MSG数组以用于消息上报 +// +// nolint:govet func toElements(e []message.IMessageElement, source message.Source, raw bool) (r []cqcode.Element) { type pair = cqcode.Pair // simplify code type pairs = []pair diff --git a/coolq/cqcode/element.go b/coolq/cqcode/element.go index b7469f9..8355925 100644 --- a/coolq/cqcode/element.go +++ b/coolq/cqcode/element.go @@ -7,16 +7,19 @@ import ( "github.com/Mrs4s/go-cqhttp/global" ) +// Element single message type Element struct { Type string Data []Pair } +// Pair key value pair type Pair struct { K string V string } +// CQCode convert to cqcode func (e *Element) CQCode() string { if e.Type == "text" { return EscapeText(e.Data[0].V) // must be {"text": value} @@ -34,6 +37,7 @@ func (e *Element) CQCode() string { return sb.String() } +// MarshalJSON see encoding/json.Marshaler func (e *Element) MarshalJSON() ([]byte, error) { buf := global.NewBuffer() defer global.PutBuffer(buf)