From 7e81432858d39b9134f67e4f8378bd573ccd5a34 Mon Sep 17 00:00:00 2001 From: Sakurapainting Date: Fri, 27 Mar 2026 19:05:54 +0800 Subject: [PATCH] style: fix CI lint --- cmd/picoclaw/internal/channel/start.go | 2 +- pkg/channels/qq/qq.go | 12 ++++++------ pkg/channels/qq/qq_test.go | 24 +++++++++++++++--------- pkg/gateway/channel_only.go | 24 ++++++++++++++++++------ 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/cmd/picoclaw/internal/channel/start.go b/cmd/picoclaw/internal/channel/start.go index 07f8b4ce2..5af0b60cc 100644 --- a/cmd/picoclaw/internal/channel/start.go +++ b/cmd/picoclaw/internal/channel/start.go @@ -21,7 +21,7 @@ func newStartCommand() *cobra.Command { Short: "Start channels without gateway side services", Long: "Start enabled channels and AgentLoop without gateway side services.\n\n" + "This mode is channel-agnostic and follows your config. Current runtime validation is primarily focused on QQ; other channels are continuously validated.", - Args: cobra.NoArgs, + Args: cobra.NoArgs, PreRunE: func(_ *cobra.Command, _ []string) error { if noTruncate && !debug { return fmt.Errorf("the --no-truncate option can only be used in conjunction with --debug (-d)") diff --git a/pkg/channels/qq/qq.go b/pkg/channels/qq/qq.go index 4a8ea1f5a..dc137ba73 100644 --- a/pkg/channels/qq/qq.go +++ b/pkg/channels/qq/qq.go @@ -35,12 +35,12 @@ import ( ) const ( - dedupTTL = 5 * time.Minute - dedupInterval = 60 * time.Second - dedupMaxSize = 10000 // hard cap on dedup map entries - typingResend = 8 * time.Second - typingSeconds = 10 - bytesPerMiB = 1024 * 1024 + dedupTTL = 5 * time.Minute + dedupInterval = 60 * time.Second + dedupMaxSize = 10000 // hard cap on dedup map entries + typingResend = 8 * time.Second + typingSeconds = 10 + bytesPerMiB = 1024 * 1024 qqStartupProbe = 15 * time.Second ) diff --git a/pkg/channels/qq/qq_test.go b/pkg/channels/qq/qq_test.go index b55357146..044cf1759 100644 --- a/pkg/channels/qq/qq_test.go +++ b/pkg/channels/qq/qq_test.go @@ -135,7 +135,9 @@ func TestHandleGroupATMessage_PrefersGroupOpenIDFromRawPayload(t *testing.T) { ctx: context.Background(), } - raw := []byte(`{"d":{"group_openid":"group-openid-abc","author":{"id":"legacy-member-id","member_openid":"member-openid-xyz"}}}`) + raw := []byte( + `{"d":{"group_openid":"group-openid-abc","author":{"id":"legacy-member-id","member_openid":"member-openid-xyz"}}}`, + ) err := ch.handleGroupATMessage()(&dto.WSPayload{RawMessage: raw}, &dto.WSGroupATMessageData{ ID: "group-openid-msg", GroupID: "legacy-group-id", @@ -169,7 +171,9 @@ func TestHandleGroupATMessage_AllowListFallsBackToLegacyMemberID(t *testing.T) { ctx: context.Background(), } - raw := []byte(`{"d":{"group_openid":"group-openid-abc","author":{"id":"legacy-member-id","member_openid":"member-openid-xyz"}}}`) + raw := []byte( + `{"d":{"group_openid":"group-openid-abc","author":{"id":"legacy-member-id","member_openid":"member-openid-xyz"}}}`, + ) err := ch.handleGroupATMessage()(&dto.WSPayload{RawMessage: raw}, &dto.WSGroupATMessageData{ ID: "group-allow-fallback", GroupID: "legacy-group-id", @@ -196,11 +200,11 @@ func TestHandleGroupATMessage_AllowListFallsBackToLegacyMemberID(t *testing.T) { func TestParseQQOpenIDs(t *testing.T) { tests := []struct { - name string - raw []byte - wantUser string - wantMember string - wantGroup string + name string + raw []byte + wantUser string + wantMember string + wantGroup string }{ { name: "empty", @@ -217,8 +221,10 @@ func TestParseQQOpenIDs(t *testing.T) { wantGroup: "", }, { - name: "all openids", - raw: []byte(`{"d":{"group_openid":"group-1","author":{"user_openid":"user-1","member_openid":"member-1"}}}`), + name: "all openids", + raw: []byte( + `{"d":{"group_openid":"group-1","author":{"user_openid":"user-1","member_openid":"member-1"}}}`, + ), wantUser: "user-1", wantMember: "member-1", wantGroup: "group-1", diff --git a/pkg/gateway/channel_only.go b/pkg/gateway/channel_only.go index 28046c393..009dccfe6 100644 --- a/pkg/gateway/channel_only.go +++ b/pkg/gateway/channel_only.go @@ -177,7 +177,11 @@ func setupAndStartChannelServices( } if runningServices.ListenHost != "" { - fmt.Printf("✓ Health endpoints available at http://%s:%d/health and /ready\n", runningServices.ListenHost, runningServices.ListenPort) + fmt.Printf( + "✓ Health endpoints available at http://%s:%d/health and /ready\n", + runningServices.ListenHost, + runningServices.ListenPort, + ) } else { fmt.Println("⚠ Shared HTTP server disabled; /health and webhook endpoints are unavailable") } @@ -190,10 +194,14 @@ func resolveChannelOnlyListenHost(host string, port int) (string, error) { return host, nil } else if isLoopbackHost(host) { if fallbackErr := probeTCPBind("0.0.0.0", port); fallbackErr == nil { - logger.WarnCF("channels", "Loopback host unavailable in channel-only mode, fallback to wildcard", map[string]any{ - "host": host, - "port": port, - }) + logger.WarnCF( + "channels", + "Loopback host unavailable in channel-only mode, fallback to wildcard", + map[string]any{ + "host": host, + "port": port, + }, + ) return "0.0.0.0", nil } return "", fmt.Errorf("bind %s:%d failed: %w", host, port, err) @@ -221,7 +229,11 @@ func isLoopbackHost(host string) bool { return ip != nil && ip.IsLoopback() } -func shutdownChannelRuntime(runningServices *channelServices, agentLoop *agent.AgentLoop, provider providers.LLMProvider) { +func shutdownChannelRuntime( + runningServices *channelServices, + agentLoop *agent.AgentLoop, + provider providers.LLMProvider, +) { if cp, ok := provider.(providers.StatefulProvider); ok { cp.Close() }