fix: resolve wastedassign lint warnings in channel subpackages

Remove wasted initial assignments before switch statements in
onebot (segType), telegram (filename), and wecom (mediaType).
This commit is contained in:
Hoshina
2026-02-26 23:36:06 +08:00
parent 35a035bdda
commit ba98069a00
7 changed files with 8 additions and 13 deletions
+1 -1
View File
@@ -192,7 +192,7 @@ func gatewayCmd(debug bool) error {
msgBus.Close()
// Use a fresh context with timeout for graceful shutdown,
// since the original ctx is already cancelled.
// since the original ctx is already canceled.
shutdownCtx, shutdownCancel := context.WithTimeout(context.Background(), 15*time.Second)
defer shutdownCancel()
+3 -3
View File
@@ -73,13 +73,13 @@ func TestPublishInbound_ContextCancel(t *testing.T) {
}
}
// Now buffer is full; publish with a cancelled context
// Now buffer is full; publish with a canceled context
cancelCtx, cancel := context.WithCancel(context.Background())
cancel()
err := mb.PublishInbound(cancelCtx, InboundMessage{Content: "overflow"})
if err == nil {
t.Fatal("expected error from cancelled context, got nil")
t.Fatal("expected error from canceled context, got nil")
}
if err != context.Canceled {
t.Fatalf("expected context.Canceled, got %v", err)
@@ -115,7 +115,7 @@ func TestConsumeInbound_ContextCancel(t *testing.T) {
_, ok := mb.ConsumeInbound(ctx)
if ok {
t.Fatal("expected ok=false when context is cancelled")
t.Fatal("expected ok=false when context is canceled")
}
}
+1 -1
View File
@@ -455,7 +455,7 @@ func (m *Manager) runWorker(ctx context.Context, name string, w *channelWorker)
func (m *Manager) sendWithRetry(ctx context.Context, name string, w *channelWorker, msg bus.OutboundMessage) {
// Rate limit: wait for token
if err := w.limiter.Wait(ctx); err != nil {
// ctx cancelled, shutting down
// ctx canceled, shutting down
return
}
+1 -1
View File
@@ -245,7 +245,7 @@ func TestSendWithRetry_ContextCancelled(t *testing.T) {
m.sendWithRetry(ctx, "test", w, msg)
// Should have called Send once, then noticed ctx cancelled during backoff
// Should have called Send once, then noticed ctx canceled during backoff
if callCount != 1 {
t.Fatalf("expected 1 Send call before context cancellation, got %d", callCount)
}
+1 -1
View File
@@ -469,7 +469,7 @@ func (c *OneBotChannel) SendMedia(ctx context.Context, msg bus.OutboundMediaMess
continue
}
segType := "image"
var segType string
switch part.Type {
case "image":
segType = "image"
-5
View File
@@ -243,11 +243,6 @@ func (c *TelegramChannel) SendMedia(ctx context.Context, msg bus.OutboundMediaMe
continue
}
filename := part.Filename
if filename == "" {
filename = "file"
}
switch part.Type {
case "image":
params := &telego.SendPhotoParams{
+1 -1
View File
@@ -221,7 +221,7 @@ func (c *WeComAppChannel) SendMedia(ctx context.Context, msg bus.OutboundMediaMe
}
// Map part type to WeCom media type
mediaType := "file"
var mediaType string
switch part.Type {
case "image":
mediaType = "image"