From e09b135cd2ff240626b8619913bb9b2b3bba242b Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Fri, 21 Mar 2025 15:15:41 +0100 Subject: [PATCH] Run gofmt. --- codecs/codecs.go | 2 +- diskwriter/diskwriter_test.go | 10 +++++----- estimator/estimator_test.go | 10 +++++----- group/group.go | 2 +- packetmap/packetmap.go | 4 ++-- packetmap/packetmap_test.go | 20 ++++++++++---------- sdpfrag/sdpfrag.go | 4 ++-- sdpfrag/sdpfrag_test.go | 4 ++-- token/jwt.go | 2 +- token/stateful_test.go | 18 +++++++++--------- 10 files changed, 38 insertions(+), 38 deletions(-) diff --git a/codecs/codecs.go b/codecs/codecs.go index ffbda0f..e4849cd 100644 --- a/codecs/codecs.go +++ b/codecs/codecs.go @@ -290,7 +290,7 @@ func PacketFlags(codec string, buf []byte) (Flags, error) { flags.Start = vp9.B flags.End = vp9.E if vp9.B && len(vp9.Payload) > 0 && - (vp9.Payload[0] & 0xc0) == 0x80 { + (vp9.Payload[0]&0xc0) == 0x80 { profile := (vp9.Payload[0] >> 4) & 0x3 if profile != 3 { flags.Keyframe = (vp9.Payload[0] & 0xC) == 0 diff --git a/diskwriter/diskwriter_test.go b/diskwriter/diskwriter_test.go index c8eb66a..fc64f0c 100644 --- a/diskwriter/diskwriter_test.go +++ b/diskwriter/diskwriter_test.go @@ -28,7 +28,7 @@ func TestAdjustOriginLocalNow(t *testing.T) { c := &diskConn{ tracks: []*diskTrack{ - &diskTrack{}, + {}, }, } for _, t := range c.tracks { @@ -56,7 +56,7 @@ func TestAdjustOriginLocalEarlier(t *testing.T) { c := &diskConn{ originLocal: earlier, tracks: []*diskTrack{ - &diskTrack{}, + {}, }, } for _, t := range c.tracks { @@ -84,7 +84,7 @@ func TestAdjustOriginLocalLater(t *testing.T) { c := &diskConn{ originLocal: later, tracks: []*diskTrack{ - &diskTrack{}, + {}, }, } for _, t := range c.tracks { @@ -111,7 +111,7 @@ func TestAdjustOriginRemote(t *testing.T) { c := &diskConn{ tracks: []*diskTrack{ - &diskTrack{ + { remoteNTP: rtptime.TimeToNTP(earlier), remoteRTP: 32, }, @@ -144,7 +144,7 @@ func TestAdjustOriginLocalRemote(t *testing.T) { c := &diskConn{ tracks: []*diskTrack{ - &diskTrack{}, + {}, }, } for _, t := range c.tracks { diff --git a/estimator/estimator_test.go b/estimator/estimator_test.go index ad68444..c0c5340 100644 --- a/estimator/estimator_test.go +++ b/estimator/estimator_test.go @@ -1,10 +1,10 @@ package estimator import ( - "testing" - "time" "sync" "sync/atomic" + "testing" + "time" "github.com/jech/galene/rtptime" ) @@ -87,7 +87,7 @@ func TestEstimatorParallel(t *testing.T) { addNow(rtptime.JiffiesPerSec / 1000) b, p := estimate() if i >= 1000 { - if b != p * 42 { + if b != p*42 { t.Errorf("%v: Got %v %v (%v), expected %v %v", n, p, b, i, 1000, p*42, ) @@ -115,7 +115,7 @@ func BenchmarkEstimator(b *testing.B) { e.Estimate() b.ResetTimer() - for i := 0; i < 1000 * b.N; i++ { + for i := 0; i < 1000*b.N; i++ { e.Accumulate(100) } @@ -130,7 +130,7 @@ func BenchmarkEstimatorParallel(b *testing.B) { e.Estimate() b.ResetTimer() - b.RunParallel(func (pb *testing.PB) { + b.RunParallel(func(pb *testing.PB) { for pb.Next() { for i := 0; i < 1000; i++ { e.Accumulate(100) diff --git a/group/group.go b/group/group.go index d89e772..2bd0fe9 100644 --- a/group/group.go +++ b/group/group.go @@ -1021,7 +1021,7 @@ func (g *Group) userExists(username string) bool { return found } -//validUsername returns true if a string is a valid username. +// validUsername returns true if a string is a valid username. // On the one hand, we want to allow usernames such as "jch@work" // or "Alice c/o Bob". On the other hand, not restricting // usernames might lead to security vulnaribilities. diff --git a/packetmap/packetmap.go b/packetmap/packetmap.go index 0635c51..477e090 100644 --- a/packetmap/packetmap.go +++ b/packetmap/packetmap.go @@ -31,7 +31,7 @@ func (m *Map) Map(seqno uint16, pid uint16) (bool, uint16, uint16) { if m.delta == 0 && m.entries == nil { if compare(m.next, seqno) <= 0 || - uint16(m.next - seqno) > 8 * 1024 { + uint16(m.next-seqno) > 8*1024 { m.next = seqno + 1 m.nextPid = pid } @@ -192,7 +192,7 @@ func (m *Map) Drop(seqno uint16, pid uint16) bool { if len(m.entries) == 0 { m.entries = []entry{ - entry{ + { first: seqno - 8192, count: 8192, delta: 0, diff --git a/packetmap/packetmap_test.go b/packetmap/packetmap_test.go index ee53080..63fdff3 100644 --- a/packetmap/packetmap_test.go +++ b/packetmap/packetmap_test.go @@ -165,14 +165,14 @@ func TestWraparound(t *testing.T) { } for i := 4; i < 256000; i++ { - ok, s, p = m.Map(uint16(i), uint16((i/2) & 0x7FFF)) + ok, s, p = m.Map(uint16(i), uint16((i/2)&0x7FFF)) if !ok || s != uint16(i-2) || p != 1 { t.Errorf("Expected %v, %v, got %v, %v, %v", uint16(i-2), 1, ok, s, p) } } - ok, s, p = m.Map((256000 & 0xFFFF) + 2, 1) + ok, s, p = m.Map((256000&0xFFFF)+2, 1) expect := uint16((256000) & 0xFFFF) if !ok || s != expect || p != 1 { t.Errorf("Expected %v, 1, got %v, %v, %v", expect, ok, s, p) @@ -202,25 +202,25 @@ func TestWraparoundDrop(t *testing.T) { t.Errorf("Expected 1, got %v, %v", ok, m.pidDelta) } - for i := 4; i < 256000; i+= 3 { - ok, s, p = m.Map(uint16(i), uint16((i/2) & 0x7FFF)) + for i := 4; i < 256000; i += 3 { + ok, s, p = m.Map(uint16(i), uint16((i/2)&0x7FFF)) if !ok || s != uint16((i-1)/3*2) || p != 1 { t.Errorf("Expected %v, %v, got %v, %v, %v", uint16((i-1)/3*2), 1, ok, s, p) } - ok, s, p = m.Map(uint16(i + 1), uint16((i/2) & 0x7FFF)) - if !ok || s != uint16((i-1)/3*2 + 1) || p != 1 { + ok, s, p = m.Map(uint16(i+1), uint16((i/2)&0x7FFF)) + if !ok || s != uint16((i-1)/3*2+1) || p != 1 { t.Errorf("Expected %v, %v, got %v, %v, %v", - uint16((i-1)/3*2 + 1), 1, ok, s, p) + uint16((i-1)/3*2+1), 1, ok, s, p) } - ok = m.Drop(uint16(i + 2), uint16((i/2) & 0x7FFF)) + ok = m.Drop(uint16(i+2), uint16((i/2)&0x7FFF)) if !ok { t.Errorf("Expected ok") } } - ok, s, p = m.Map((256000 & 0xFFFF) + 4, 0) - expect := uint16(((256000 - 1)/3*2 + 4) & 0xFFFF) + ok, s, p = m.Map((256000&0xFFFF)+4, 0) + expect := uint16(((256000-1)/3*2 + 4) & 0xFFFF) if !ok || s != expect || p != 1 { t.Errorf("Expected %v, 1, got %v, %v, %v", expect, ok, s, p) } diff --git a/sdpfrag/sdpfrag.go b/sdpfrag/sdpfrag.go index f4fe4a4..5f642db 100644 --- a/sdpfrag/sdpfrag.go +++ b/sdpfrag/sdpfrag.go @@ -234,8 +234,8 @@ func getCandidates(as []sdp.Attribute, mid *string, index *uint16, ufrag string) continue } c := webrtc.ICECandidateInit{ - Candidate: a.Value, - SDPMid: mid, + Candidate: a.Value, + SDPMid: mid, SDPMLineIndex: index, } if ufrag != "" { diff --git a/sdpfrag/sdpfrag_test.go b/sdpfrag/sdpfrag_test.go index a970c65..c42810e 100644 --- a/sdpfrag/sdpfrag_test.go +++ b/sdpfrag/sdpfrag_test.go @@ -1,8 +1,8 @@ package sdpfrag import ( - "testing" "reflect" + "testing" "github.com/pion/sdp/v3" ) @@ -238,7 +238,7 @@ func testRoundtrip(t *testing.T, sdpfrag string) { } func TestRoundtrip(t *testing.T) { - type test struct { name, frag string } + type test struct{ name, frag string } for _, tt := range []test{ {"sdpfragTrickle", sdpfragTrickle}, {"sdpfragEndOfCandidates", sdpfragEndOfCandidates}, diff --git a/token/jwt.go b/token/jwt.go index 4ff31dc..e336e9c 100644 --- a/token/jwt.go +++ b/token/jwt.go @@ -100,7 +100,7 @@ func ParseKeys(keys []map[string]any, alg, kid string) ([]jwt.VerificationKey, e ks := make([]jwt.VerificationKey, 0, len(keys)) for _, ky := range keys { // return all keys if alg and kid are not specified - if alg != "" && ky["alg"] != alg { + if alg != "" && ky["alg"] != alg { continue } if kid != "" && ky["kid"] != kid { diff --git a/token/stateful_test.go b/token/stateful_test.go index d74407a..8b90cfc 100644 --- a/token/stateful_test.go +++ b/token/stateful_test.go @@ -17,7 +17,7 @@ func timeEqual(a, b *time.Time) bool { return true } - if a!= nil && b != nil { + if a != nil && b != nil { return (*a).Equal(*b) } @@ -228,14 +228,14 @@ func TestTokenStorage(t *testing.T) { user2 := "user2" user3 := "user3" tokens := []*Stateful{ - &Stateful{ + { Token: "tok1", Group: "test", Username: &user1, Permissions: []string{"present", "message"}, Expires: &future, }, - &Stateful{ + { Token: "tok2", Group: "test", Username: &user2, @@ -243,7 +243,7 @@ func TestTokenStorage(t *testing.T) { Expires: &nearFuture, NotBefore: &past, }, - &Stateful{ + { Token: "tok3", Group: "test", Username: &user3, @@ -323,35 +323,35 @@ func TestExpire(t *testing.T) { user := "user" tokens := []*Stateful{ - &Stateful{ + { Token: "tok1", Group: "test", Username: &user, Permissions: []string{"present", "message"}, Expires: &now, }, - &Stateful{ + { Token: "tok2", Group: "test", Username: &user, Permissions: []string{"present", "message"}, Expires: &future, }, - &Stateful{ + { Token: "tok3", Group: "test", Username: &user, Permissions: []string{"present", "message"}, Expires: &now, }, - &Stateful{ + { Token: "tok4", Group: "test", Username: &user, Permissions: []string{"present", "message"}, Expires: &past, }, - &Stateful{ + { Token: "tok5", Group: "test", Username: &user,