From ab24c667926268c3d9cfe14dab926844fbdb03fa Mon Sep 17 00:00:00 2001 From: Vsevolod Strukchinsky Date: Tue, 20 Oct 2026 19:39:04 +0500 Subject: [PATCH] lint: fix the issues golangci-lint v2.14.0 reports on draft-22 The Lint job has failed on every push since 835f6db, and every PR against draft-22 inherits it (e.g. dependabot #121). Nine issues, all from 835f6db..85049b6: - golines/goimports: wrap four long lines; move "bytes" into the stdlib import group in metrics_test.go - embeddedstructfieldcheck: blank line after the embedded field in prioritizedSendStream and deadlineRecordingSendStream - modernize embedlit: set the promoted field directly in wrapSendStream's prioritizedSendStream literal - revive unused-parameter: blockedSendStream.Write ignores its input No behavior change. Lint-only, so there is no regression test; the Lint job itself is the check that goes red without this. Co-Authored-By: Claude Opus 5.5 --- pkg/moqt/session/datastream_timeout_test.go | 8 ++++++-- pkg/moqt/session/urgency_test.go | 4 +++- pkg/moqt/session/wtconn/wtconn.go | 3 ++- pkg/relay/handler_fanout.go | 10 +++++++++- pkg/relay/metrics_test.go | 9 +++++++-- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/pkg/moqt/session/datastream_timeout_test.go b/pkg/moqt/session/datastream_timeout_test.go index 2d58a50b..5ed363b6 100644 --- a/pkg/moqt/session/datastream_timeout_test.go +++ b/pkg/moqt/session/datastream_timeout_test.go @@ -667,7 +667,7 @@ func (b *blockedSendStream) SetWriteDeadline(t time.Time) error { // a deadline that was not armed is a failure, not a hang. var errNeverArmed = errors.New("blockedSendStream: no write deadline was armed") -func (b *blockedSendStream) Write(p []byte) (int, error) { +func (b *blockedSendStream) Write([]byte) (int, error) { b.mu.Lock() deadline := b.deadline b.mu.Unlock() @@ -751,6 +751,7 @@ func TestObjectDeliveryTimeoutLiftsTheDeadline(t *testing.T) { // set on it and writes at once. type deadlineRecordingSendStream struct { *fakeSendStream + deadlines []time.Time } @@ -781,7 +782,10 @@ func BenchmarkWriteObjectWithDeadline(b *testing.B) { func TestObjectDeliveryTimeoutNoDeadlineWithoutTimeout(t *testing.T) { dst := newFakeSendStream() out := session.NewOutgoingSubgroupStream(dst) - if err := out.WriteObjectReceivedAt(time.Now().Add(-time.Hour), &message.SubgroupObject{Payload: []byte("x")}); err != nil { + if err := out.WriteObjectReceivedAt( + time.Now().Add(-time.Hour), + &message.SubgroupObject{Payload: []byte("x")}, + ); err != nil { t.Fatalf("an hour-old object with no timeout should still be written: %v", err) } } diff --git a/pkg/moqt/session/urgency_test.go b/pkg/moqt/session/urgency_test.go index bb14b330..c01768be 100644 --- a/pkg/moqt/session/urgency_test.go +++ b/pkg/moqt/session/urgency_test.go @@ -14,7 +14,9 @@ func TestUrgency(t *testing.T) { subscriber uint8 want int8 }{{0, 1}, {1, 1}, {64, 2}, {128, 4}, {200, 5}, {255, 7}} { - if got := session.Urgency(session.StreamPriority{Subscriber: tc.subscriber, Publisher: 255, GroupKey: 1 << 60}); got != tc.want { + if got := session.Urgency( + session.StreamPriority{Subscriber: tc.subscriber, Publisher: 255, GroupKey: 1 << 60}, + ); got != tc.want { t.Errorf("Urgency(subscriber %d) = %d, want %d", tc.subscriber, got, tc.want) } } diff --git a/pkg/moqt/session/wtconn/wtconn.go b/pkg/moqt/session/wtconn/wtconn.go index d3a093c9..6d30b13c 100644 --- a/pkg/moqt/session/wtconn/wtconn.go +++ b/pkg/moqt/session/wtconn/wtconn.go @@ -189,13 +189,14 @@ type prioritizer interface { // the transport will do. func wrapSendStream(s *webtransport.SendStream) session.SendStream { if p, ok := any(s).(prioritizer); ok { - return &prioritizedSendStream{sendStream: sendStream{s: s}, p: p} + return &prioritizedSendStream{s: s, p: p} } return &sendStream{s: s} } type prioritizedSendStream struct { sendStream + p prioritizer } diff --git a/pkg/relay/handler_fanout.go b/pkg/relay/handler_fanout.go index 8c0bdf30..8de5ce32 100644 --- a/pkg/relay/handler_fanout.go +++ b/pkg/relay/handler_fanout.go @@ -576,7 +576,15 @@ func (h *sessionHandler) runFanout(ctx context.Context, stream *session.Incoming } // Counted after the dedup claim, so redundant copies don't count. - h.metrics.ObjectReceived(ref, ReceivedObject{Name: entry.FullName, Subgroup: hdr.SubgroupID, HeaderAt: headerAt, Properties: obj.Properties}) + h.metrics.ObjectReceived( + ref, + ReceivedObject{ + Name: entry.FullName, + Subgroup: hdr.SubgroupID, + HeaderAt: headerAt, + Properties: obj.Properties, + }, + ) cached := &cache.CachedObject{ GroupID: hdr.GroupID, diff --git a/pkg/relay/metrics_test.go b/pkg/relay/metrics_test.go index 9614ded9..48a022ee 100644 --- a/pkg/relay/metrics_test.go +++ b/pkg/relay/metrics_test.go @@ -1,6 +1,7 @@ package relay_test import ( + "bytes" "errors" "maps" "sync" @@ -8,7 +9,6 @@ import ( "testing" "time" - "bytes" "github.com/floatdrop/moq-go/pkg/moqt/message" "github.com/floatdrop/moq-go/pkg/moqt/session" "github.com/floatdrop/moq-go/pkg/relay" @@ -67,7 +67,12 @@ func (m *recordingMetrics) SubscriptionClosed(relay.TrackRef) { m.subsClosed.Add func (m *recordingMetrics) ObjectReceived(_ relay.TrackRef, o relay.ReceivedObject) { m.mu.Lock() - m.lastReceived = relay.ReceivedObject{Name: o.Name, Subgroup: o.Subgroup, HeaderAt: o.HeaderAt, Properties: bytes.Clone(o.Properties)} + m.lastReceived = relay.ReceivedObject{ + Name: o.Name, + Subgroup: o.Subgroup, + HeaderAt: o.HeaderAt, + Properties: bytes.Clone(o.Properties), + } m.mu.Unlock() m.received.Add(1) }