From 6a868b9e50410492b851b5ffaf380d9457ed61fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=B5=D0=BD=D1=82=D1=8C=D0=B5=D0=B2?= Date: Sun, 22 Feb 2026 10:45:01 +0300 Subject: [PATCH] Run go fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Александр Мелентьев --- .github/workflows/pr.yml | 3 +++ pkg/auth/store.go | 2 +- pkg/channels/onebot.go | 9 +++------ pkg/channels/wecom.go | 2 +- pkg/config/config.go | 4 ++-- pkg/utils/message.go | 5 +---- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 11547d67b..47f76b356 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -54,6 +54,9 @@ jobs: with: go-version-file: go.mod + - name: Run go generate + run: go generate ./... + - name: Run go fix run: go fix ./... diff --git a/pkg/auth/store.go b/pkg/auth/store.go index 64708421b..26641c769 100644 --- a/pkg/auth/store.go +++ b/pkg/auth/store.go @@ -11,7 +11,7 @@ type AuthCredential struct { AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token,omitempty"` AccountID string `json:"account_id,omitempty"` - ExpiresAt time.Time `json:"expires_at,omitempty"` + ExpiresAt time.Time `json:"expires_at"` Provider string `json:"provider"` AuthMethod string `json:"auth_method"` Email string `json:"email,omitempty"` diff --git a/pkg/channels/onebot.go b/pkg/channels/onebot.go index cee8ad9d3..f316b33d3 100644 --- a/pkg/channels/onebot.go +++ b/pkg/channels/onebot.go @@ -315,10 +315,7 @@ func (c *OneBotChannel) sendAPIRequest(action string, params any, timeout time.D } func (c *OneBotChannel) reconnectLoop() { - interval := time.Duration(c.config.ReconnectInterval) * time.Second - if interval < 5*time.Second { - interval = 5 * time.Second - } + interval := max(time.Duration(c.config.ReconnectInterval)*time.Second, 5*time.Second) for { select { @@ -973,8 +970,8 @@ func (c *OneBotChannel) checkGroupTrigger( if prefix == "" { continue } - if strings.HasPrefix(content, prefix) { - return true, strings.TrimSpace(strings.TrimPrefix(content, prefix)) + if after, ok := strings.CutPrefix(content, prefix); ok { + return true, strings.TrimSpace(after) } } diff --git a/pkg/channels/wecom.go b/pkg/channels/wecom.go index e24157f5c..8942c5b7b 100644 --- a/pkg/channels/wecom.go +++ b/pkg/channels/wecom.go @@ -87,7 +87,7 @@ type WeComBotReplyMessage struct { MsgType string `json:"msgtype"` Text struct { Content string `json:"content"` - } `json:"text,omitempty"` + } `json:"text"` } // NewWeComBotChannel creates a new WeCom Bot channel instance diff --git a/pkg/config/config.go b/pkg/config/config.go index 20556011a..a0c2e8af7 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -49,9 +49,9 @@ func (f *FlexibleStringSlice) UnmarshalJSON(data []byte) error { type Config struct { Agents AgentsConfig `json:"agents"` Bindings []AgentBinding `json:"bindings,omitempty"` - Session SessionConfig `json:"session,omitempty"` + Session SessionConfig `json:"session"` Channels ChannelsConfig `json:"channels"` - Providers ProvidersConfig `json:"providers,omitempty"` + Providers ProvidersConfig `json:"providers"` ModelList []ModelConfig `json:"model_list"` // New model-centric provider configuration Gateway GatewayConfig `json:"gateway"` Tools ToolsConfig `json:"tools"` diff --git a/pkg/utils/message.go b/pkg/utils/message.go index a65506edc..157ffd3d6 100644 --- a/pkg/utils/message.go +++ b/pkg/utils/message.go @@ -13,10 +13,7 @@ func SplitMessage(content string, maxLen int) []string { var messages []string // Dynamic buffer: 10% of maxLen, but at least 50 chars if possible - codeBlockBuffer := max(maxLen/10, 50) - if codeBlockBuffer > maxLen/2 { - codeBlockBuffer = maxLen / 2 - } + codeBlockBuffer := min(max(maxLen/10, 50), maxLen/2) for len(content) > 0 { if len(content) <= maxLen {