diff --git a/.golangci.yml b/.golangci.yml index 2c80f690b..089f935dc 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -24,7 +24,8 @@ linters: - exportloopref - goconst - goimports - - gofmt + - gofmt # redundant, since gofmt *should* be a no-op after gofumpt + - gofumpt - gosimple - ineffassign - misspell diff --git a/benchmark/benchmark_suite_test.go b/benchmark/benchmark_suite_test.go index 26df5f92c..d23344293 100644 --- a/benchmark/benchmark_suite_test.go +++ b/benchmark/benchmark_suite_test.go @@ -3,11 +3,10 @@ package benchmark import ( "flag" "math/rand" + "testing" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - - "testing" ) func TestBenchmark(t *testing.T) { @@ -15,9 +14,7 @@ func TestBenchmark(t *testing.T) { RunSpecs(t, "Benchmark Suite") } -var ( - size int // file size in MB, will be read from flags -) +var size int // file size in MB, will be read from flags func init() { flag.IntVar(&size, "size", 50, "data length (in MB)") diff --git a/conn_id_manager_test.go b/conn_id_manager_test.go index 9690c6c0c..76e2b4ae5 100644 --- a/conn_id_manager_test.go +++ b/conn_id_manager_test.go @@ -243,7 +243,6 @@ var _ = Describe("Connection ID Manager", func() { StatelessResetToken: protocol.StatelessResetToken{16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}, })).To(Succeed()) Expect(m.Get()).To(Equal(protocol.ConnectionID{1, 2, 3, 4})) - }) It("initiates subsequent updates when enough packets are sent", func() { diff --git a/crypto_stream_test.go b/crypto_stream_test.go index a4d39014c..a4f92b65e 100644 --- a/crypto_stream_test.go +++ b/crypto_stream_test.go @@ -22,9 +22,7 @@ func createHandshakeMessage(len int) []byte { } var _ = Describe("Crypto Stream", func() { - var ( - str cryptoStream - ) + var str cryptoStream BeforeEach(func() { str = newCryptoStream() diff --git a/fuzzing/handshake/fuzz.go b/fuzzing/handshake/fuzz.go index bf068183d..0d49b813f 100644 --- a/fuzzing/handshake/fuzz.go +++ b/fuzzing/handshake/fuzz.go @@ -21,9 +21,11 @@ import ( "github.com/lucas-clemente/quic-go/internal/wire" ) -var cert, clientCert *tls.Certificate -var certPool, clientCertPool *x509.CertPool -var sessionTicketKey = [32]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32} +var ( + cert, clientCert *tls.Certificate + certPool, clientCertPool *x509.CertPool + sessionTicketKey = [32]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32} +) func init() { priv, err := rsa.GenerateKey(rand.Reader, 1024) @@ -183,6 +185,7 @@ func (r *runner) OnError(err error) { (*r.client).Close() (*r.server).Close() } + func (r *runner) Errored() bool { r.Lock() defer r.Unlock() @@ -190,8 +193,10 @@ func (r *runner) Errored() bool { } func (r *runner) DropKeys(protocol.EncryptionLevel) {} -const alpn = "fuzzing" -const alpnWrong = "wrong" +const ( + alpn = "fuzzing" + alpnWrong = "wrong" +) func toEncryptionLevel(n uint8) protocol.EncryptionLevel { switch n % 3 { @@ -238,8 +243,10 @@ func getTransportParameters(seed uint8) *wire.TransportParameters { } // PrefixLen is the number of bytes used for configuration -const PrefixLen = 12 -const confLen = 5 +const ( + PrefixLen = 12 + confLen = 5 +) // Fuzz fuzzes the TLS 1.3 handshake used by QUIC. //go:generate go run ./cmd/corpus.go diff --git a/fuzzing/internal/helper/helper.go b/fuzzing/internal/helper/helper.go index b4a4ed328..c62118203 100644 --- a/fuzzing/internal/helper/helper.go +++ b/fuzzing/internal/helper/helper.go @@ -33,7 +33,7 @@ func WriteCorpusFile(path string, data []byte) error { } } hash := sha1.Sum(data) - return ioutil.WriteFile(filepath.Join(path, hex.EncodeToString(hash[:])), data, 0644) + return ioutil.WriteFile(filepath.Join(path, hex.EncodeToString(hash[:])), data, 0o644) } // WriteCorpusFileWithPrefix writes data to a corpus file in directory path. diff --git a/http3/client.go b/http3/client.go index 3a5df2552..bf850c0ea 100644 --- a/http3/client.go +++ b/http3/client.go @@ -19,8 +19,10 @@ import ( // Note that 0-RTT data doesn't provide replay protection. const MethodGet0RTT = "GET_0RTT" -const defaultUserAgent = "quic-go HTTP/3" -const defaultMaxResponseHeaderBytes = 10 * 1 << 20 // 10 MB +const ( + defaultUserAgent = "quic-go HTTP/3" + defaultMaxResponseHeaderBytes = 10 * 1 << 20 // 10 MB +) var defaultQuicConfig = &quic.Config{ MaxIncomingStreams: -1, // don't allow the server to create bidirectional streams diff --git a/http3/response_writer.go b/http3/response_writer.go index 8f4d69604..3288e4cb6 100644 --- a/http3/response_writer.go +++ b/http3/response_writer.go @@ -22,8 +22,10 @@ type responseWriter struct { logger utils.Logger } -var _ http.ResponseWriter = &responseWriter{} -var _ http.Flusher = &responseWriter{} +var ( + _ http.ResponseWriter = &responseWriter{} + _ http.Flusher = &responseWriter{} +) func newResponseWriter(stream io.Writer, logger utils.Logger) *responseWriter { return &responseWriter{ diff --git a/http3/roundtrip_test.go b/http3/roundtrip_test.go index 0f357412a..aa136952d 100644 --- a/http3/roundtrip_test.go +++ b/http3/roundtrip_test.go @@ -23,6 +23,7 @@ type mockClient struct { func (m *mockClient) RoundTrip(req *http.Request) (*http.Response, error) { return &http.Response{Request: req}, nil } + func (m *mockClient) Close() error { m.closed = true return nil diff --git a/http3/server.go b/http3/server.go index be4417980..5e755297d 100644 --- a/http3/server.go +++ b/http3/server.go @@ -35,13 +35,11 @@ type contextKey struct { func (k *contextKey) String() string { return "quic-go/http3 context value " + k.name } -var ( - // ServerContextKey is a context key. It can be used in HTTP - // handlers with Context.Value to access the server that - // started the handler. The associated value will be of - // type *http3.Server. - ServerContextKey = &contextKey{"http3-server"} -) +// ServerContextKey is a context key. It can be used in HTTP +// handlers with Context.Value to access the server that +// started the handler. The associated value will be of +// type *http3.Server. +var ServerContextKey = &contextKey{"http3-server"} type requestError struct { err error diff --git a/integrationtests/self/handshake_test.go b/integrationtests/self/handshake_test.go index 0b9c92627..d1c5a9693 100644 --- a/integrationtests/self/handshake_test.go +++ b/integrationtests/self/handshake_test.go @@ -356,7 +356,6 @@ var _ = Describe("Handshake tests", func() { Expect(err).To(HaveOccurred()) Expect(err.(*qerr.QuicError).ErrorCode).To(Equal(qerr.ConnectionRefused)) }) - }) Context("ALPN", func() { diff --git a/integrationtests/self/key_update_test.go b/integrationtests/self/key_update_test.go index bb061a768..54317d04b 100644 --- a/integrationtests/self/key_update_test.go +++ b/integrationtests/self/key_update_test.go @@ -16,8 +16,10 @@ import ( . "github.com/onsi/gomega" ) -var sentHeaders []*logging.ExtendedHeader -var receivedHeaders []*logging.ExtendedHeader +var ( + sentHeaders []*logging.ExtendedHeader + receivedHeaders []*logging.ExtendedHeader +) func countKeyPhases() (sent, received int) { lastKeyPhase := protocol.KeyPhaseOne @@ -75,6 +77,7 @@ func (t *connTracer) BufferedPacket(logging.PacketType) func (t *connTracer) DroppedPacket(logging.PacketType, logging.ByteCount, logging.PacketDropReason) {} func (t *connTracer) UpdatedMetrics(rttStats *logging.RTTStats, cwnd, bytesInFlight logging.ByteCount, packetsInFlight int) { } + func (t *connTracer) LostPacket(logging.EncryptionLevel, logging.PacketNumber, logging.PacketLossReason) { } func (t *connTracer) UpdatedCongestionState(logging.CongestionState) {} diff --git a/integrationtests/tools/proxy/proxy_suite_test.go b/integrationtests/tools/proxy/proxy_suite_test.go index 6e413a82f..dd07db3b7 100644 --- a/integrationtests/tools/proxy/proxy_suite_test.go +++ b/integrationtests/tools/proxy/proxy_suite_test.go @@ -1,10 +1,10 @@ package quicproxy import ( + "testing" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - - "testing" ) func TestQuicGo(t *testing.T) { diff --git a/internal/ackhandler/ackhandler_suite_test.go b/internal/ackhandler/ackhandler_suite_test.go index 9e7e07776..734d6f48e 100644 --- a/internal/ackhandler/ackhandler_suite_test.go +++ b/internal/ackhandler/ackhandler_suite_test.go @@ -1,11 +1,11 @@ package ackhandler import ( + "testing" + "github.com/golang/mock/gomock" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - - "testing" ) func TestCrypto(t *testing.T) { diff --git a/internal/ackhandler/received_packet_history_test.go b/internal/ackhandler/received_packet_history_test.go index 6c48a70e8..8054e1a23 100644 --- a/internal/ackhandler/received_packet_history_test.go +++ b/internal/ackhandler/received_packet_history_test.go @@ -9,9 +9,7 @@ import ( ) var _ = Describe("receivedPacketHistory", func() { - var ( - hist *receivedPacketHistory - ) + var hist *receivedPacketHistory BeforeEach(func() { hist = newReceivedPacketHistory() diff --git a/internal/ackhandler/sent_packet_handler.go b/internal/ackhandler/sent_packet_handler.go index cb34f57d8..9f5486472 100644 --- a/internal/ackhandler/sent_packet_handler.go +++ b/internal/ackhandler/sent_packet_handler.go @@ -88,8 +88,10 @@ type sentPacketHandler struct { logger utils.Logger } -var _ SentPacketHandler = &sentPacketHandler{} -var _ sentPacketTracker = &sentPacketHandler{} +var ( + _ SentPacketHandler = &sentPacketHandler{} + _ sentPacketTracker = &sentPacketHandler{} +) func newSentPacketHandler( initialPacketNumber protocol.PacketNumber, diff --git a/internal/ackhandler/sent_packet_handler_test.go b/internal/ackhandler/sent_packet_handler_test.go index 9f3a1a765..338144072 100644 --- a/internal/ackhandler/sent_packet_handler_test.go +++ b/internal/ackhandler/sent_packet_handler_test.go @@ -232,10 +232,11 @@ var _ = Describe("SentPacketHandler", func() { ping := &wire.PingFrame{} handler.SentPacket(ackElicitingPacket(&Packet{ PacketNumber: 13, - Frames: []Frame{{Frame: ping, OnAcked: func(f wire.Frame) { - Expect(f).To(Equal(ping)) - acked = true - }, + Frames: []Frame{{ + Frame: ping, OnAcked: func(f wire.Frame) { + Expect(f).To(Equal(ping)) + acked = true + }, }}, })) ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 13, Largest: 13}}} diff --git a/internal/congestion/congestion_suite_test.go b/internal/congestion/congestion_suite_test.go index 577ee5bf7..6a0f7ed7a 100644 --- a/internal/congestion/congestion_suite_test.go +++ b/internal/congestion/congestion_suite_test.go @@ -1,10 +1,10 @@ package congestion import ( + "testing" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - - "testing" ) func TestCongestion(t *testing.T) { diff --git a/internal/congestion/cubic.go b/internal/congestion/cubic.go index 5e0139849..392ec7b81 100644 --- a/internal/congestion/cubic.go +++ b/internal/congestion/cubic.go @@ -17,9 +17,11 @@ import ( // 1024*1024^3 (first 1024 is from 0.100^3) // where 0.100 is 100 ms which is the scaling round trip time. -const cubeScale = 40 -const cubeCongestionWindowScale = 410 -const cubeFactor protocol.ByteCount = 1 << cubeScale / cubeCongestionWindowScale / maxDatagramSize +const ( + cubeScale = 40 + cubeCongestionWindowScale = 410 + cubeFactor protocol.ByteCount = 1 << cubeScale / cubeCongestionWindowScale / maxDatagramSize +) const defaultNumConnections = 1 diff --git a/internal/congestion/cubic_sender.go b/internal/congestion/cubic_sender.go index 936fb4cc5..7c5ee3b0d 100644 --- a/internal/congestion/cubic_sender.go +++ b/internal/congestion/cubic_sender.go @@ -63,8 +63,10 @@ type cubicSender struct { tracer logging.ConnectionTracer } -var _ SendAlgorithm = &cubicSender{} -var _ SendAlgorithmWithDebugInfos = &cubicSender{} +var ( + _ SendAlgorithm = &cubicSender{} + _ SendAlgorithmWithDebugInfos = &cubicSender{} +) // NewCubicSender makes a new cubic sender func NewCubicSender(clock Clock, rttStats *utils.RTTStats, reno bool, tracer logging.ConnectionTracer) *cubicSender { diff --git a/internal/congestion/cubic_sender_test.go b/internal/congestion/cubic_sender_test.go index b341ee7a3..83b4a7002 100644 --- a/internal/congestion/cubic_sender_test.go +++ b/internal/congestion/cubic_sender_test.go @@ -9,8 +9,10 @@ import ( . "github.com/onsi/gomega" ) -const initialCongestionWindowPackets = 10 -const defaultWindowTCP = protocol.ByteCount(initialCongestionWindowPackets) * maxDatagramSize +const ( + initialCongestionWindowPackets = 10 + defaultWindowTCP = protocol.ByteCount(initialCongestionWindowPackets) * maxDatagramSize +) type mockClock time.Time diff --git a/internal/congestion/cubic_test.go b/internal/congestion/cubic_test.go index eb3b5bedd..390a14884 100644 --- a/internal/congestion/cubic_test.go +++ b/internal/congestion/cubic_test.go @@ -9,11 +9,13 @@ import ( . "github.com/onsi/gomega" ) -const numConnections uint32 = 2 -const nConnectionBeta float32 = (float32(numConnections) - 1 + beta) / float32(numConnections) -const nConnectionBetaLastMax float32 = (float32(numConnections) - 1 + betaLastMax) / float32(numConnections) -const nConnectionAlpha float32 = 3 * float32(numConnections) * float32(numConnections) * (1 - nConnectionBeta) / (1 + nConnectionBeta) -const maxCubicTimeInterval = 30 * time.Millisecond +const ( + numConnections uint32 = 2 + nConnectionBeta float32 = (float32(numConnections) - 1 + beta) / float32(numConnections) + nConnectionBetaLastMax float32 = (float32(numConnections) - 1 + betaLastMax) / float32(numConnections) + nConnectionAlpha float32 = 3 * float32(numConnections) * float32(numConnections) * (1 - nConnectionBeta) / (1 + nConnectionBeta) + maxCubicTimeInterval = 30 * time.Millisecond +) var _ = Describe("Cubic", func() { var ( diff --git a/internal/congestion/hybrid_slow_start.go b/internal/congestion/hybrid_slow_start.go index f41c1e5c3..b5ae3d5eb 100644 --- a/internal/congestion/hybrid_slow_start.go +++ b/internal/congestion/hybrid_slow_start.go @@ -17,8 +17,10 @@ const hybridStartMinSamples = uint32(8) // Exit slow start if the min rtt has increased by more than 1/8th. const hybridStartDelayFactorExp = 3 // 2^3 = 8 // The original paper specifies 2 and 8ms, but those have changed over time. -const hybridStartDelayMinThresholdUs = int64(4000) -const hybridStartDelayMaxThresholdUs = int64(16000) +const ( + hybridStartDelayMinThresholdUs = int64(4000) + hybridStartDelayMaxThresholdUs = int64(16000) +) // HybridSlowStart implements the TCP hybrid slow start algorithm type HybridSlowStart struct { diff --git a/internal/congestion/hybrid_slow_start_test.go b/internal/congestion/hybrid_slow_start_test.go index fee8945e2..4b947db64 100644 --- a/internal/congestion/hybrid_slow_start_test.go +++ b/internal/congestion/hybrid_slow_start_test.go @@ -9,9 +9,7 @@ import ( ) var _ = Describe("Hybrid slow start", func() { - var ( - slowStart HybridSlowStart - ) + var slowStart HybridSlowStart BeforeEach(func() { slowStart = HybridSlowStart{} @@ -71,5 +69,4 @@ var _ = Describe("Hybrid slow start", func() { // RTT provided. Expect(slowStart.ShouldExitSlowStart(rtt+10*time.Millisecond, rtt, 100)).To(BeTrue()) }) - }) diff --git a/internal/flowcontrol/flowcontrol_suite_test.go b/internal/flowcontrol/flowcontrol_suite_test.go index 16da9ed26..6a325b423 100644 --- a/internal/flowcontrol/flowcontrol_suite_test.go +++ b/internal/flowcontrol/flowcontrol_suite_test.go @@ -1,11 +1,11 @@ package flowcontrol import ( + "testing" + "github.com/golang/mock/gomock" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - - "testing" ) func TestCrypto(t *testing.T) { diff --git a/internal/handshake/crypto_setup.go b/internal/handshake/crypto_setup.go index aa8b2cd1f..3107fffb9 100644 --- a/internal/handshake/crypto_setup.go +++ b/internal/handshake/crypto_setup.go @@ -137,8 +137,10 @@ type cryptoSetup struct { has1RTTOpener bool } -var _ qtls.RecordLayer = &cryptoSetup{} -var _ CryptoSetup = &cryptoSetup{} +var ( + _ qtls.RecordLayer = &cryptoSetup{} + _ CryptoSetup = &cryptoSetup{} +) // NewCryptoSetupClient creates a new crypto setup for the client func NewCryptoSetupClient( diff --git a/internal/handshake/handshake_suite_test.go b/internal/handshake/handshake_suite_test.go index 807b4afe3..1c763b760 100644 --- a/internal/handshake/handshake_suite_test.go +++ b/internal/handshake/handshake_suite_test.go @@ -4,6 +4,7 @@ import ( "crypto/tls" "encoding/hex" "strings" + "testing" "github.com/lucas-clemente/quic-go/internal/qtls" @@ -11,8 +12,6 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - - "testing" ) func TestHandshake(t *testing.T) { diff --git a/internal/handshake/header_protector.go b/internal/handshake/header_protector.go index 309af6b18..e1c72c3b6 100644 --- a/internal/handshake/header_protector.go +++ b/internal/handshake/header_protector.go @@ -26,7 +26,6 @@ func newHeaderProtector(suite *qtls.CipherSuiteTLS13, trafficSecret []byte, isLo default: panic(fmt.Sprintf("Invalid cipher suite id: %d", suite.ID)) } - } type aesHeaderProtector struct { diff --git a/internal/handshake/retry.go b/internal/handshake/retry.go index b589b9911..30be193c3 100644 --- a/internal/handshake/retry.go +++ b/internal/handshake/retry.go @@ -13,7 +13,7 @@ import ( var retryAEAD cipher.AEAD func init() { - var key = [16]byte{0xcc, 0xce, 0x18, 0x7e, 0xd0, 0x9a, 0x09, 0xd0, 0x57, 0x28, 0x15, 0x5a, 0x6c, 0xb9, 0x6b, 0xe1} + key := [16]byte{0xcc, 0xce, 0x18, 0x7e, 0xd0, 0x9a, 0x09, 0xd0, 0x57, 0x28, 0x15, 0x5a, 0x6c, 0xb9, 0x6b, 0xe1} aes, err := aes.NewCipher(key[:]) if err != nil { @@ -26,9 +26,11 @@ func init() { retryAEAD = aead } -var retryBuf bytes.Buffer -var retryMutex sync.Mutex -var retryNonce = [12]byte{0xe5, 0x49, 0x30, 0xf9, 0x7f, 0x21, 0x36, 0xf0, 0x53, 0x0a, 0x8c, 0x1c} +var ( + retryBuf bytes.Buffer + retryMutex sync.Mutex + retryNonce = [12]byte{0xe5, 0x49, 0x30, 0xf9, 0x7f, 0x21, 0x36, 0xf0, 0x53, 0x0a, 0x8c, 0x1c} +) // GetRetryIntegrityTag calculates the integrity tag on a Retry packet func GetRetryIntegrityTag(retry []byte, origDestConnID protocol.ConnectionID) *[16]byte { diff --git a/internal/handshake/updatable_aead.go b/internal/handshake/updatable_aead.go index 67247ae0c..fb3ae9a35 100644 --- a/internal/handshake/updatable_aead.go +++ b/internal/handshake/updatable_aead.go @@ -61,8 +61,10 @@ type updatableAEAD struct { nonceBuf []byte } -var _ ShortHeaderOpener = &updatableAEAD{} -var _ ShortHeaderSealer = &updatableAEAD{} +var ( + _ ShortHeaderOpener = &updatableAEAD{} + _ ShortHeaderSealer = &updatableAEAD{} +) func newUpdatableAEAD(rttStats *utils.RTTStats, tracer logging.ConnectionTracer, logger utils.Logger) *updatableAEAD { return &updatableAEAD{ diff --git a/internal/protocol/protocol_suite_test.go b/internal/protocol/protocol_suite_test.go index 204a3680e..60da0157a 100644 --- a/internal/protocol/protocol_suite_test.go +++ b/internal/protocol/protocol_suite_test.go @@ -1,10 +1,10 @@ package protocol import ( + "testing" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - - "testing" ) func TestProtocol(t *testing.T) { diff --git a/internal/protocol/stream.go b/internal/protocol/stream.go index 988dcc82f..ad7de864b 100644 --- a/internal/protocol/stream.go +++ b/internal/protocol/stream.go @@ -61,7 +61,7 @@ func (s StreamID) InitiatedBy() Perspective { return PerspectiveServer } -//Type says if this is a unidirectional or bidirectional stream +// Type says if this is a unidirectional or bidirectional stream func (s StreamID) Type() StreamType { if s%4 >= 2 { return StreamTypeUni diff --git a/internal/qerr/quic_error_test.go b/internal/qerr/quic_error_test.go index a984e1867..4d547287a 100644 --- a/internal/qerr/quic_error_test.go +++ b/internal/qerr/quic_error_test.go @@ -52,7 +52,6 @@ var _ = Describe("QUIC Transport Errors", func() { err := NewCryptoError(42, "") Expect(err.IsCryptoError()).To(BeTrue()) Expect(err.IsApplicationError()).To(BeFalse()) - }) }) diff --git a/internal/utils/rtt_stats_test.go b/internal/utils/rtt_stats_test.go index 7a29518cf..1be304308 100644 --- a/internal/utils/rtt_stats_test.go +++ b/internal/utils/rtt_stats_test.go @@ -10,9 +10,7 @@ import ( ) var _ = Describe("RTT stats", func() { - var ( - rttStats *RTTStats - ) + var rttStats *RTTStats BeforeEach(func() { rttStats = NewRTTStats() diff --git a/internal/utils/utils_suite_test.go b/internal/utils/utils_suite_test.go index 2874819b8..9ecb8c052 100644 --- a/internal/utils/utils_suite_test.go +++ b/internal/utils/utils_suite_test.go @@ -1,10 +1,10 @@ package utils import ( + "testing" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - - "testing" ) func TestCrypto(t *testing.T) { diff --git a/internal/wire/ack_frame_test.go b/internal/wire/ack_frame_test.go index 1d9f37708..15c0f00ba 100644 --- a/internal/wire/ack_frame_test.go +++ b/internal/wire/ack_frame_test.go @@ -197,7 +197,6 @@ var _ = Describe("ACK Frame (for IETF QUIC)", func() { Expect(err).To(MatchError(io.EOF)) } }) - }) }) diff --git a/internal/wire/log_test.go b/internal/wire/log_test.go index 92874d24c..03f89dc18 100644 --- a/internal/wire/log_test.go +++ b/internal/wire/log_test.go @@ -53,7 +53,6 @@ var _ = Describe("Frame logging", func() { } LogFrame(logger, frame, false) Expect(buf.String()).To(ContainSubstring("\t<- &wire.CryptoFrame{Offset: 42, Data length: 123, Offset + Data length: 165}\n")) - }) It("logs STREAM frames", func() { diff --git a/internal/wire/max_data_frame.go b/internal/wire/max_data_frame.go index 4fd9a1b1c..e6496d886 100644 --- a/internal/wire/max_data_frame.go +++ b/internal/wire/max_data_frame.go @@ -27,7 +27,7 @@ func parseMaxDataFrame(r *bytes.Reader, _ protocol.VersionNumber) (*MaxDataFrame return frame, nil } -//Write writes a MAX_STREAM_DATA frame +// Write writes a MAX_STREAM_DATA frame func (f *MaxDataFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error { b.WriteByte(0x10) utils.WriteVarInt(b, uint64(f.MaximumData)) diff --git a/internal/wire/transport_parameters.go b/internal/wire/transport_parameters.go index d8cf5177b..1f81eb23f 100644 --- a/internal/wire/transport_parameters.go +++ b/internal/wire/transport_parameters.go @@ -315,7 +315,7 @@ func (p *TransportParameters) readNumericTransportParameter( func (p *TransportParameters) Marshal(pers protocol.Perspective) []byte { b := &bytes.Buffer{} - //add a greased value + // add a greased value utils.WriteVarInt(b, uint64(27+31*rand.Intn(100))) length := rand.Intn(16) randomData := make([]byte, length) diff --git a/internal/wire/wire_suite_test.go b/internal/wire/wire_suite_test.go index f3b11d417..cc23c18b8 100644 --- a/internal/wire/wire_suite_test.go +++ b/internal/wire/wire_suite_test.go @@ -2,13 +2,12 @@ package wire import ( "bytes" + "testing" "github.com/lucas-clemente/quic-go/internal/protocol" "github.com/lucas-clemente/quic-go/internal/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - - "testing" ) func TestWire(t *testing.T) { diff --git a/interop/utils/logging.go b/interop/utils/logging.go index 623ec2129..4c35c9741 100644 --- a/interop/utils/logging.go +++ b/interop/utils/logging.go @@ -33,7 +33,7 @@ func GetQLOGWriter() (func(perspective logging.Perspective, connID []byte) io.Wr return nil, nil } if _, err := os.Stat(qlogDir); os.IsNotExist(err) { - if err := os.MkdirAll(qlogDir, 0666); err != nil { + if err := os.MkdirAll(qlogDir, 0o666); err != nil { return nil, fmt.Errorf("failed to create qlog dir %s: %s", qlogDir, err.Error()) } } diff --git a/metrics/metrics.go b/metrics/metrics.go index e9bdac5d4..070ccc13e 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -196,6 +196,7 @@ func (t *connTracer) LostPacket(encLevel logging.EncryptionLevel, _ logging.Pack lostPackets.M(1), ) } + func (t *connTracer) UpdatedPTOCount(value uint32) { if value == 0 { return diff --git a/qlog/qlog.go b/qlog/qlog.go index 7c0134123..a394c6bd3 100644 --- a/qlog/qlog.go +++ b/qlog/qlog.go @@ -89,7 +89,8 @@ func (t *connectionTracer) run() { }, EventFields: eventFields[:], }, - }} + }, + } if err := enc.Encode(tl); err != nil { panic(fmt.Sprintf("qlog encoding into a bytes.Buffer failed: %s", err)) } diff --git a/quic_suite_test.go b/quic_suite_test.go index 1798fff7d..a26b35046 100644 --- a/quic_suite_test.go +++ b/quic_suite_test.go @@ -2,12 +2,11 @@ package quic import ( "sync" + "testing" "github.com/golang/mock/gomock" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - - "testing" ) func TestQuicGo(t *testing.T) { diff --git a/receive_stream.go b/receive_stream.go index a92baba1f..63b141bc1 100644 --- a/receive_stream.go +++ b/receive_stream.go @@ -52,8 +52,10 @@ type receiveStream struct { version protocol.VersionNumber } -var _ ReceiveStream = &receiveStream{} -var _ receiveStreamI = &receiveStream{} +var ( + _ ReceiveStream = &receiveStream{} + _ receiveStreamI = &receiveStream{} +) func newReceiveStream( streamID protocol.StreamID, diff --git a/send_stream.go b/send_stream.go index 7fc3194e7..cb7a828df 100644 --- a/send_stream.go +++ b/send_stream.go @@ -57,8 +57,10 @@ type sendStream struct { version protocol.VersionNumber } -var _ SendStream = &sendStream{} -var _ sendStreamI = &sendStream{} +var ( + _ SendStream = &sendStream{} + _ sendStreamI = &sendStream{} +) func newSendStream( streamID protocol.StreamID, diff --git a/server.go b/server.go index b62fe73f4..29cbed672 100644 --- a/server.go +++ b/server.go @@ -103,8 +103,10 @@ type baseServer struct { logger utils.Logger } -var _ Listener = &baseServer{} -var _ unknownPacketHandler = &baseServer{} +var ( + _ Listener = &baseServer{} + _ unknownPacketHandler = &baseServer{} +) type earlyServer struct{ *baseServer } diff --git a/session.go b/session.go index 3f8ff2775..5bede9e6d 100644 --- a/session.go +++ b/session.go @@ -213,9 +213,11 @@ type session struct { logger utils.Logger } -var _ Session = &session{} -var _ EarlySession = &session{} -var _ streamSender = &session{} +var ( + _ Session = &session{} + _ EarlySession = &session{} + _ streamSender = &session{} +) var newSession = func( conn sendConn, diff --git a/session_test.go b/session_test.go index 83e2bf717..805cf4614 100644 --- a/session_test.go +++ b/session_test.go @@ -2701,6 +2701,5 @@ var _ = Describe("Client Session", func() { tracer.EXPECT().DroppedPacket(gomock.Any(), gomock.Any(), gomock.Any()) Expect(sess.handlePacketImpl(wrapPacket(initialPacket))).To(BeFalse()) }) - }) }) diff --git a/stream.go b/stream.go index a1c5feccf..03edae809 100644 --- a/stream.go +++ b/stream.go @@ -53,8 +53,10 @@ type streamI interface { handleMaxStreamDataFrame(*wire.MaxStreamDataFrame) } -var _ receiveStreamI = (streamI)(nil) -var _ sendStreamI = (streamI)(nil) +var ( + _ receiveStreamI = (streamI)(nil) + _ sendStreamI = (streamI)(nil) +) // A Stream assembles the data from StreamFrames and provides a super-convenient Read-Interface //