Repository: pion/rtp
Pull request #89 (2020-09-17 03:21:54)

Update CI configs to v0.4.7
Update lint scripts and CI configs.

codecov[bot]: # [Codecov](https://codecov.io/gh/pion/rtp/pull/89?src=pr&el=h1) Report
> Merging [#89](https://codecov.io/gh/pion/rtp/pull/89?src=pr&el=desc) into [master](https://codecov.io/gh/pion/rtp/commit/0d8026ebf7c048a65f30b053f3ce22e7d5e738ee?el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pion/rtp/pull/89/graphs/tree.svg?width=650&height=150&src=pr&token=4KrbiBsspj)](https://codecov.io/gh/pion/rtp/pull/89?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master      #89   +/-   ##
=======================================
  Coverage   90.98%   90.98%           
=======================================
  Files          13       13           
  Lines         677      677           
=======================================
  Hits          616      616           
  Misses         43       43           
  Partials       18       18           
```

| Flag | Coverage Δ | |
|---|---|---|
| #go | `90.98% <ø> (ø)` | |
| #wasm | `?` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.


------

[Continue to review full report at Codecov](https://codecov.io/gh/pion/rtp/pull/89?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pion/rtp/pull/89?src=pr&el=footer). Last update [0d8026e...c0a8ef7](https://codecov.io/gh/pion/rtp/pull/89?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Sean-Der: I am actively working on this one!

Patch:
diff --git a/.golangci.yml b/.golangci.yml
index 570f17b..4213697 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -3,6 +3,80 @@ linters-settings:
     check-shadowing: true
   misspell:
     locale: US
+  exhaustive:
+    default-signifies-exhaustive: true
+
+linters:
+  enable:
+    - asciicheck       # Simple linter to check that your code does not contain non-ASCII identifiers
+    - bodyclose        # checks whether HTTP response body is closed successfully
+    - deadcode         # Finds unused code
+    - depguard         # Go linter that checks if package imports are in a list of acceptable packages
+    - dogsled          # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
+    - dupl             # Tool for code clone detection
+    - errcheck         # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
+    - exhaustive       # check exhaustiveness of enum switch statements
+    - exportloopref    # checks for pointers to enclosing loop variables
+    - gci              # Gci control golang package import order and make it always deterministic.
+    - gochecknoglobals # Checks that no globals are present in Go code
+    - gochecknoinits   # Checks that no init functions are present in Go code
+    - gocognit         # Computes and checks the cognitive complexity of functions
+    - goconst          # Finds repeated strings that could be replaced by a constant
+    - gocritic         # The most opinionated Go source code linter
+    - godox            # Tool for detection of FIXME, TODO and other comment keywords
+    - goerr113         # Golang linter to check the errors handling expressions
+    - gofmt            # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
+    - gofumpt          # Gofumpt checks whether code was gofumpt-ed.
+    - goheader         # Checks is file header matches to pattern
+    - goimports        # Goimports does everything that gofmt does. Additionally it checks unused imports
+    - golint           # Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes
+    - gomodguard       # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations.
+    - goprintffuncname # Checks that printf-like functions are named with `f` at the end
+    - gosec            # Inspects source code for security problems
+    - gosimple         # Linter for Go source code that specializes in simplifying a code
+    - govet            # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
+    - ineffassign      # Detects when assignments to existing variables are not used
+    - misspell         # Finds commonly misspelled English words in comments
+    - nakedret         # Finds naked returns in functions greater than a specified function length
+    - noctx            # noctx finds sending http request without context.Context
+    - scopelint        # Scopelint checks for unpinned variables in go programs
+    - staticcheck      # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
+    - structcheck      # Finds unused struct fields
+    - stylecheck       # Stylecheck is a replacement for golint
+    - typecheck        # Like the front-end of a Go compiler, parses and type-checks Go code
+    - unconvert        # Remove unnecessary type conversions
+    - unparam          # Reports unused function parameters
+    - unused           # Checks Go code for unused constants, variables, functions and types
+    - varcheck         # Finds unused global variables and constants
+    - whitespace       # Tool for detection of leading and trailing whitespace
+  disable:
+    - funlen           # Tool for detection of long functions
+    - gocyclo          # Computes and checks the cyclomatic complexity of functions
+    - godot            # Check if comments end in a period
+    - gomnd            # An analyzer to detect magic numbers.
+    - lll              # Reports long lines
+    - maligned         # Tool to detect Go structs that would take less memory if their fields were sorted
+    - nestif           # Reports deeply nested if statements
+    - nlreturn         # nlreturn checks for a new line before return and branch statements to increase code clarity
+    - nolintlint       # Reports ill-formed or insufficient nolint directives
+    - prealloc         # Finds slice declarations that could potentially be preallocated
+    - rowserrcheck     # checks whether Err of rows is checked successfully
+    - sqlclosecheck    # Checks that sql.Rows and sql.Stmt are closed.
+    - testpackage      # linter that makes you use a separate _test package
+    - wsl              # Whitespace Linter - Forces you to use empty lines!
+
+issues:
+  exclude-rules:
+    # Allow complex tests, better to be self contained
+    - path: _test\.go
+      linters:
+        - gocognit
+
+    # Allow complex main function in examples
+    - path: examples
+      text: "of func `main` is high"
+      linters:
+        - gocognit
 
 run:
   skip-dirs-use-default: false
diff --git a/abssendtimeextension.go b/abssendtimeextension.go
index dc86c0d..fc9731d 100644
--- a/abssendtimeextension.go
+++ b/abssendtimeextension.go
@@ -57,7 +57,7 @@ func toNtpTime(t time.Time) uint64 {
 	var f uint64
 	u := uint64(t.UnixNano())
 	s = u / 1e9
-	s += 0x83AA7E80 //offset in seconds between unix epoch and ntp epoch
+	s += 0x83AA7E80 // offset in seconds between unix epoch and ntp epoch
 	f = u % 1e9
 	f <<= 32
 	f /= 1e9
diff --git a/audiolevelextension.go b/audiolevelextension.go
index d0ba8b4..f8701e1 100644
--- a/audiolevelextension.go
+++ b/audiolevelextension.go
@@ -9,9 +9,7 @@ const (
 	audioLevelExtensionSize = 1
 )
 
-var (
-	errAudioLevelOverflow = errors.New("audio level overflow")
-)
+var errAudioLevelOverflow = errors.New("audio level overflow")
 
 // AudioLevelExtension is a extension payload format described in
 // https://tools.ietf.org/html/rfc6464
diff --git a/codecs/error.go b/codecs/error.go
index fa4d17e..38ee907 100644
--- a/codecs/error.go
+++ b/codecs/error.go
@@ -3,7 +3,9 @@ package codecs
 import "errors"
 
 var (
-	errShortPacket  = errors.New("packet is not large enough")
-	errNilPacket    = errors.New("invalid nil packet")
-	errTooManyPDiff = errors.New("too many PDiff")
+	errShortPacket          = errors.New("packet is not large enough")
+	errNilPacket            = errors.New("invalid nil packet")
+	errTooManyPDiff         = errors.New("too many PDiff")
+	errTooManySpatialLayers = errors.New("too many spatial layers")
+	errUnhandledNALUType    = errors.New("NALU Type is unhandled")
 )
diff --git a/codecs/h264_packet.go b/codecs/h264_packet.go
index b03faa8..df57970 100644
--- a/codecs/h264_packet.go
+++ b/codecs/h264_packet.go
@@ -118,10 +118,10 @@ func (p *H264Payloader) Payload(mtu int, payload []byte) [][]byte {
 			out[0] |= naluRefIdc
 
 			// +---------------+
-			//|0|1|2|3|4|5|6|7|
-			//+-+-+-+-+-+-+-+-+
-			//|S|E|R|  Type   |
-			//+---------------+
+			// |0|1|2|3|4|5|6|7|
+			// +-+-+-+-+-+-+-+-+
+			// |S|E|R|  Type   |
+			// +---------------+
 
 			out[1] = naluType
 			if naluDataRemaining == naluDataLength {
@@ -150,9 +150,9 @@ type H264Packet struct {
 // Unmarshal parses the passed byte slice and stores the result in the H264Packet this method is called upon
 func (p *H264Packet) Unmarshal(payload []byte) ([]byte, error) {
 	if payload == nil {
-		return nil, fmt.Errorf("invalid nil packet")
+		return nil, errNilPacket
 	} else if len(payload) <= 2 {
-		return nil, fmt.Errorf("Payload is not large enough to container header and payload")
+		return nil, fmt.Errorf("%w: %d <= 2", errShortPacket, len(payload))
 	}
 
 	// NALU Types
@@ -170,7 +170,7 @@ func (p *H264Packet) Unmarshal(payload []byte) ([]byte, error) {
 			currOffset += stapaNALULengthSize
 
 			if len(payload) < currOffset+naluSize {
-				return nil, fmt.Errorf("STAP-A declared size(%d) is larger than buffer(%d)", naluSize, len(payload)-currOffset)
+				return nil, fmt.Errorf("%w STAP-A declared size(%d) is larger than buffer(%d)", errShortPacket, naluSize, len(payload)-currOffset)
 			}
 
 			result = append(result, annexbNALUStartCode()...)
@@ -181,7 +181,7 @@ func (p *H264Packet) Unmarshal(payload []byte) ([]byte, error) {
 
 	case naluType == fuaNALUType:
 		if len(payload) < fuaHeaderSize {
-			return nil, fmt.Errorf("Payload is not large enough to be FU-A")
+			return nil, errShortPacket
 		}
 
 		if payload[1]&fuaStartBitmask != 0 {
@@ -197,5 +197,5 @@ func (p *H264Packet) Unmarshal(payload []byte) ([]byte, error) {
 		return payload[fuaHeaderSize:], nil
 	}
 
-	return nil, fmt.Errorf("nalu type %d is currently not handled", naluType)
+	return nil, fmt.Errorf("%w: %d", errUnhandledNALUType, naluType)
 }
diff --git a/codecs/opus_packet.go b/codecs/opus_packet.go
index 8557338..504741f 100644
--- a/codecs/opus_packet.go
+++ b/codecs/opus_packet.go
@@ -1,9 +1,5 @@
 package codecs
 
-import (
-	"fmt"
-)
-
 // OpusPayloader payloads Opus packets
 type OpusPayloader struct{}
 
@@ -26,11 +22,11 @@ type OpusPacket struct {
 // Unmarshal parses the passed byte slice and stores the result in the OpusPacket this method is called upon
 func (p *OpusPacket) Unmarshal(packet []byte) ([]byte, error) {
 	if packet == nil {
-		return nil, fmt.Errorf("invalid nil packet")
-	}
-	if len(packet) == 0 {
-		return nil, fmt.Errorf("Payload is not large enough")
+		return nil, errNilPacket
+	} else if len(packet) == 0 {
+		return nil, errShortPacket
 	}
+
 	p.Payload = packet
 	return packet, nil
 }
diff --git a/codecs/vp8_packet.go b/codecs/vp8_packet.go
index d91663d..7ade7da 100644
--- a/codecs/vp8_packet.go
+++ b/codecs/vp8_packet.go
@@ -1,9 +1,5 @@
 package codecs
 
-import (
-	"fmt"
-)
-
 // VP8Payloader payloads VP8 packets
 type VP8Payloader struct{}
 
@@ -85,13 +81,13 @@ type VP8Packet struct {
 // Unmarshal parses the passed byte slice and stores the result in the VP8Packet this method is called upon
 func (p *VP8Packet) Unmarshal(payload []byte) ([]byte, error) {
 	if payload == nil {
-		return nil, fmt.Errorf("invalid nil packet")
+		return nil, errNilPacket
 	}
 
 	payloadLen := len(payload)
 
 	if payloadLen < 4 {
-		return nil, fmt.Errorf("Payload is not large enough to container header")
+		return nil, errShortPacket
 	}
 
 	payloadIndex := 0
@@ -128,7 +124,7 @@ func (p *VP8Packet) Unmarshal(payload []byte) ([]byte, error) {
 	}
 
 	if payloadIndex >= payloadLen {
-		return nil, fmt.Errorf("Payload is not large enough")
+		return nil, errShortPacket
 	}
 	p.Payload = payload[payloadIndex:]
 	return p.Payload, nil
diff --git a/codecs/vp9_packet.go b/codecs/vp9_packet.go
index 336659d..5cb619b 100644
--- a/codecs/vp9_packet.go
+++ b/codecs/vp9_packet.go
@@ -1,8 +1,6 @@
 package codecs
 
 import (
-	"errors"
-
 	"github.com/pion/randutil"
 )
 
@@ -258,7 +256,7 @@ func (p *VP9Packet) parseLayerInfoCommon(packet []byte, pos int) (int, error) {
 	p.D = packet[pos]&0x01 != 0
 
 	if p.SID >= maxSpatialLayers {
-		return pos, errors.New("too many spatial layers")
+		return pos, errTooManySpatialLayers
 	}
 
 	pos++
diff --git a/error.go b/error.go
index 57f47db..5458c6f 100644
--- a/error.go
+++ b/error.go
@@ -4,5 +4,18 @@ import (
 	"errors"
 )
 
-var errHeaderSizeInsufficient = errors.New("RTP header size insufficient")
-var errHeaderSizeInsufficientForExtension = errors.New("RTP header size insufficient for extension")
+var (
+	errHeaderSizeInsufficient             = errors.New("RTP header size insufficient")
+	errHeaderSizeInsufficientForExtension = errors.New("RTP header size insufficient for extension")
+	errTooSmall                           = errors.New("buffer too small")
+	errHeaderExtensionsNotEnabled         = errors.New("h.Extension not enabled")
+	errHeaderExtensionNotFound            = errors.New("extension not found")
+
+	errRFC8285OneByteHeaderIDRange = errors.New("header extension id must be between 1 and 14 for RFC 5285 one byte extensions")
+	errRFC8285OneByteHeaderSize    = errors.New("header extension payload must be 16bytes or less for RFC 5285 one byte extensions")
+
+	errRFC8285TwoByteHeaderIDRange = errors.New("header extension id must be between 1 and 255 for RFC 5285 two byte extensions")
+	errRFC8285TwoByteHeaderSize    = errors.New("header extension payload must be 255bytes or less for RFC 5285 two byte extensions")
+
+	errRFC3550HeaderIDRange = errors.New("header extension id must be 0 for non-RFC 5285 extensions")
+)
diff --git a/packet.go b/packet.go
index b0e5777..c5d5c5f 100644
--- a/packet.go
+++ b/packet.go
@@ -12,8 +12,6 @@ type Extension struct {
 	payload []byte
 }
 
-// TODO(@kixelated) Remove Header.PayloadOffset and Packet.Raw
-
 // Header represents an RTP packet header
 // NOTE: PayloadOffset is populated by Marshal/Unmarshal and should not be modified
 type Header struct {
@@ -80,9 +78,9 @@ func (p Packet) String() string {
 }
 
 // Unmarshal parses the passed byte slice and stores the result in the Header this method is called upon
-func (h *Header) Unmarshal(rawPacket []byte) error {
+func (h *Header) Unmarshal(rawPacket []byte) error { //nolint:gocognit
 	if len(rawPacket) < headerLength {
-		return fmt.Errorf("RTP header size insufficient; %d < %d", len(rawPacket), headerLength)
+		return fmt.Errorf("%w: %d < %d", errHeaderSizeInsufficient, len(rawPacket), headerLength)
 	}
 
 	/*
@@ -187,7 +185,7 @@ func (h *Header) Unmarshal(rawPacket []byte) error {
 
 		default: // RFC3550 Extension
 			if len(rawPacket) < currOffset+extensionLength {
-				return fmt.Errorf("RTP header size insufficient for extension length; %d < %d", len(rawPacket), currOffset+extensionLength)
+				return fmt.Errorf("%w: %d < %d", errHeaderSizeInsufficientForExtension, len(rawPacket), currOffset+extensionLength)
 			}
 
 			extension := Extension{id: 0, payload: rawPacket[currOffset : currOffset+extensionLength]}
@@ -298,7 +296,7 @@ func (h *Header) MarshalTo(buf []byte) (n int, err error) {
 		default: // RFC3550 Extension
 			extlen := len(h.Extensions[0].payload)
 			if extlen%4 != 0 {
-				//the payload must be in 32-bit words.
+				// the payload must be in 32-bit words.
 				return 0, io.ErrShortBuffer
 			}
 			n += copy(buf[n:], h.Extensions[0].payload)
@@ -353,28 +351,28 @@ func (h *Header) MarshalSize() int {
 }
 
 // SetExtension sets an RTP header extension
-func (h *Header) SetExtension(id uint8, payload []byte) error {
+func (h *Header) SetExtension(id uint8, payload []byte) error { //nolint:gocognit
 	if h.Extension {
 		switch h.ExtensionProfile {
 		// RFC 8285 RTP One Byte Header Extension
 		case extensionProfileOneByte:
 			if id < 1 || id > 14 {
-				return fmt.Errorf("header extension id must be between 1 and 14 for RFC 5285 extensions")
+				return fmt.Errorf("%w actual(%d)", errRFC8285OneByteHeaderIDRange, id)
 			}
 			if len(payload) > 16 {
-				return fmt.Errorf("header extension payload must be 16bytes or less for RFC 5285 one byte extensions")
+				return fmt.Errorf("%w actual(%d)", errRFC8285OneByteHeaderSize, len(payload))
 			}
 		// RFC 8285 RTP Two Byte Header Extension
 		case extensionProfileTwoByte:
 			if id < 1 || id > 255 {
-				return fmt.Errorf("header extension id must be between 1 and 255 for RFC 5285 extensions")
+				return fmt.Errorf("%w actual(%d)", errRFC8285TwoByteHeaderIDRange, id)
 			}
 			if len(payload) > 255 {
-				return fmt.Errorf("header extension payload must be 255bytes or less for RFC 5285 two byte extensions")
+				return fmt.Errorf("%w actual(%d)", errRFC8285TwoByteHeaderSize, len(payload))
 			}
 		default: // RFC3550 Extension
 			if id != 0 {
-				return fmt.Errorf("header extension id must be 0 for none RFC 5285 extensions")
+				return fmt.Errorf("%w actual(%d)", errRFC3550HeaderIDRange, id)
 			}
 		}
 
@@ -419,7 +417,7 @@ func (h *Header) GetExtension(id uint8) []byte {
 // DelExtension Removes an RTP Header extension
 func (h *Header) DelExtension(id uint8) error {
 	if !h.Extension {
-		return fmt.Errorf("h.Extension not enabled")
+		return errHeaderExtensionsNotEnabled
 	}
 	for i, extension := range h.Extensions {
 		if extension.id == id {
@@ -427,7 +425,7 @@ func (h *Header) DelExtension(id uint8) error {
 			return nil
 		}
 	}
-	return fmt.Errorf("extension not found")
+	return errHeaderExtensionNotFound
 }
 
 // Marshal serializes the packet into bytes.
diff --git a/packetizer.go b/packetizer.go
index 30c4edb..5a8482f 100644
--- a/packetizer.go
+++ b/packetizer.go
@@ -23,8 +23,8 @@ type packetizer struct {
 	Sequencer        Sequencer
 	Timestamp        uint32
 	ClockRate        uint32
-	extensionNumbers struct { //put extension numbers in here. If they're 0, the extension is disabled (0 is not a legal extension number)
-		AbsSendTime int //http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
+	extensionNumbers struct { // put extension numbers in here. If they're 0, the extension is disabled (0 is not a legal extension number)
+		AbsSendTime int // http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
 	}
 	timegen func() time.Time
 }
@@ -76,7 +76,7 @@ func (p *packetizer) Packetize(payload []byte, samples uint32) []*Packet {
 
 	if len(packets) != 0 && p.extensionNumbers.AbsSendTime != 0 {
 		sendTime := NewAbsSendTimeExtension(p.timegen())
-		//apply http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
+		// apply http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
 		b, err := sendTime.Marshal()
 		if err != nil {
 			return nil // never happens
diff --git a/transportccextension.go b/transportccextension.go
index 5dcf5b3..f9ffe4e 100644
--- a/transportccextension.go
+++ b/transportccextension.go
@@ -2,7 +2,6 @@ package rtp
 
 import (
 	"encoding/binary"
-	"errors"
 )
 
 const (
@@ -10,10 +9,6 @@ const (
 	transportCCExtensionSize = 2
 )
 
-var (
-	errTooSmall = errors.New("buffer too small")
-)
-
 // TransportCCExtension is a extension payload format in
 // https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01
 // 0                   1                   2                   3


Test patch:
diff --git a/abssendtimeextension_test.go b/abssendtimeextension_test.go
index 9bae6c3..16243fd 100644
--- a/abssendtimeextension_test.go
+++ b/abssendtimeextension_test.go
@@ -66,7 +66,7 @@ func TestAbsSendTimeExtension_Estimate(t *testing.T) {
 	tests := []struct {
 		sendNTP    uint64
 		receiveNTP uint64
-	}{ //FFFFFFC000000000 mask of second
+	}{ // FFFFFFC000000000 mask of second
 		{0xa0c65b1000100000, 0xa0c65b1001000000}, // not carried
 		{0xa0c65b3f00000000, 0xa0c65b4001000000}, // carried during transmission
 	}
diff --git a/audiolevelextension_test.go b/audiolevelextension_test.go
index 13d553f..b1ad89f 100644
--- a/audiolevelextension_test.go
+++ b/audiolevelextension_test.go
@@ -2,6 +2,7 @@ package rtp
 
 import (
 	"bytes"
+	"errors"
 	"testing"
 )
 
@@ -10,7 +11,7 @@ func TestAudioLevelExtensionTooSmall(t *testing.T) {
 
 	rawData := []byte{}
 
-	if err := a.Unmarshal(rawData); err != errTooSmall {
+	if err := a.Unmarshal(rawData); !errors.Is(err, errTooSmall) {
 		t.Fatal("err != errTooSmall")
 	}
 }
@@ -73,7 +74,7 @@ func TestAudioLevelExtensionLevelOverflow(t *testing.T) {
 		Voice: false,
 	}
 
-	if _, err := a.Marshal(); err != errAudioLevelOverflow {
+	if _, err := a.Marshal(); !errors.Is(err, errAudioLevelOverflow) {
 		t.Fatal("err != errAudioLevelOverflow")
 	}
 }
diff --git a/codecs/g711_packet_test.go b/codecs/g711_packet_test.go
index 21aa514..d260a06 100644
--- a/codecs/g711_packet_test.go
+++ b/codecs/g711_packet_test.go
@@ -1,4 +1,4 @@
-package codecs
+package codecs //nolint:dupl
 
 import (
 	"bytes"
@@ -15,19 +15,18 @@ func TestG711Payloader(t *testing.T) {
 		testmtu = 1500
 	)
 
-	//generate random 8-bit g722 samples
+	// generate random 8-bit g722 samples
 	samples := make([]byte, testlen)
 	_, err := rand.Read(samples)
-
 	if err != nil {
 		t.Fatal("RNG Error: ", err)
 	}
 
-	//make a copy, for payloader input
+	// make a copy, for payloader input
 	samplesIn := make([]byte, testlen)
 	copy(samplesIn, samples)
 
-	//split our samples into payloads
+	// split our samples into payloads
 	payloads := p.Payload(testmtu, samplesIn)
 
 	outcnt := int(math.Ceil(float64(testlen) / testmtu))
diff --git a/codecs/g722_packet_test.go b/codecs/g722_packet_test.go
index 2ae9f22..8d1198b 100644
--- a/codecs/g722_packet_test.go
+++ b/codecs/g722_packet_test.go
@@ -1,4 +1,4 @@
-package codecs
+package codecs //nolint:dupl
 
 import (
 	"bytes"
@@ -15,19 +15,18 @@ func TestG722Payloader(t *testing.T) {
 		testmtu = 1500
 	)
 
-	//generate random 8-bit g722 samples
+	// generate random 8-bit g722 samples
 	samples := make([]byte, testlen)
 	_, err := rand.Read(samples)
-
 	if err != nil {
 		t.Fatal("RNG Error: ", err)
 	}
 
-	//make a copy, for payloader input
+	// make a copy, for payloader input
 	samplesIn := make([]byte, testlen)
 	copy(samplesIn, samples)
 
-	//split our samples into payloads
+	// split our samples into payloads
 	payloads := p.Payload(testmtu, samplesIn)
 
 	outcnt := int(math.Ceil(float64(testlen) / testmtu))
diff --git a/codecs/opus_packet_test.go b/codecs/opus_packet_test.go
index f80c7cf..5366a6b 100644
--- a/codecs/opus_packet_test.go
+++ b/codecs/opus_packet_test.go
@@ -1,15 +1,13 @@
 package codecs
 
 import (
-	"fmt"
+	"errors"
 	"testing"
 )
 
 func TestOpusPacket_Unmarshal(t *testing.T) {
 	pck := OpusPacket{}
 
-	errPayloadTooSmall := fmt.Errorf("Payload is not large enough")
-
 	// Nil packet
 	raw, err := pck.Unmarshal(nil)
 	if raw != nil {
@@ -24,8 +22,8 @@ func TestOpusPacket_Unmarshal(t *testing.T) {
 	if raw != nil {
 		t.Fatal("Result should be nil in case of error")
 	}
-	if err == nil || err.Error() != errPayloadTooSmall.Error() {
-		t.Fatal("Error should be:", errPayloadTooSmall)
+	if !errors.Is(err, errShortPacket) {
+		t.Fatal("Error should be:", errShortPacket)
 	}
 
 	// Normal packet
diff --git a/codecs/vp8_packet_test.go b/codecs/vp8_packet_test.go
index d326802..1c062c3 100644
--- a/codecs/vp8_packet_test.go
+++ b/codecs/vp8_packet_test.go
@@ -1,22 +1,19 @@
 package codecs
 
 import (
-	"fmt"
+	"errors"
 	"testing"
 )
 
 func TestVP8Packet_Unmarshal(t *testing.T) {
 	pck := VP8Packet{}
 
-	errSmallerThanHeaderLen := fmt.Errorf("Payload is not large enough to container header")
-	errPayloadTooSmall := fmt.Errorf("Payload is not large enough")
-
 	// Nil packet
 	raw, err := pck.Unmarshal(nil)
 	if raw != nil {
 		t.Fatal("Result should be nil in case of error")
 	}
-	if err == nil || err.Error() != errNilPacket.Error() {
+	if !errors.Is(err, errNilPacket) {
 		t.Fatal("Error should be:", errNilPacket)
 	}
 
@@ -25,8 +22,8 @@ func TestVP8Packet_Unmarshal(t *testing.T) {
 	if raw != nil {
 		t.Fatal("Result should be nil in case of error")
 	}
-	if err == nil || err.Error() != errSmallerThanHeaderLen.Error() {
-		t.Fatal("Error should be:", errSmallerThanHeaderLen)
+	if !errors.Is(err, errShortPacket) {
+		t.Fatal("Error should be:", errShortPacket)
 	}
 
 	// Payload smaller than header size
@@ -34,8 +31,8 @@ func TestVP8Packet_Unmarshal(t *testing.T) {
 	if raw != nil {
 		t.Fatal("Result should be nil in case of error")
 	}
-	if err == nil || err.Error() != errSmallerThanHeaderLen.Error() {
-		t.Fatal("Error should be:", errSmallerThanHeaderLen)
+	if !errors.Is(err, errShortPacket) {
+		t.Fatal("Error should be:", errShortPacket)
 	}
 
 	// Normal payload
@@ -70,8 +67,8 @@ func TestVP8Packet_Unmarshal(t *testing.T) {
 	if raw != nil {
 		t.Fatal("Result should be nil in case of error")
 	}
-	if err == nil || err.Error() != errPayloadTooSmall.Error() {
-		t.Fatal("Error should be:", errPayloadTooSmall)
+	if !errors.Is(err, errShortPacket) {
+		t.Fatal("Error should be:", errShortPacket)
 	}
 
 	// Header size, X and L
@@ -106,8 +103,8 @@ func TestVP8Packet_Unmarshal(t *testing.T) {
 	if raw != nil {
 		t.Fatal("Result should be nil in case of error")
 	}
-	if err == nil || err.Error() != errPayloadTooSmall.Error() {
-		t.Fatal("Error should be:", errPayloadTooSmall)
+	if !errors.Is(err, errShortPacket) {
+		t.Fatal("Error should be:", errShortPacket)
 	}
 }
 
diff --git a/codecs/vp9_packet_test.go b/codecs/vp9_packet_test.go
index 572614a..d226324 100644
--- a/codecs/vp9_packet_test.go
+++ b/codecs/vp9_packet_test.go
@@ -1,6 +1,7 @@
 package codecs
 
 import (
+	"errors"
 	"fmt"
 	"math/rand"
 	"reflect"
@@ -186,7 +187,7 @@ func TestVP9Packet_Unmarshal(t *testing.T) {
 				if raw != nil {
 					t.Error("Result should be nil in case of error")
 				}
-				if err != c.err {
+				if !errors.Is(err, c.err) {
 					t.Errorf("Error should be '%v', got '%v'", c.err, err)
 				}
 			}
@@ -195,7 +196,7 @@ func TestVP9Packet_Unmarshal(t *testing.T) {
 }
 
 func TestVP9Payloader_Payload(t *testing.T) {
-	r0 := int(rand.New(rand.NewSource(0)).Int31n(0x7FFF))
+	r0 := int(rand.New(rand.NewSource(0)).Int31n(0x7FFF)) //nolint:gosec
 	var rands [][2]byte
 	for i := 0; i < 10; i++ {
 		rands = append(rands, [2]byte{byte(r0>>8) | 0x80, byte(r0 & 0xFF)})
@@ -259,7 +260,7 @@ func TestVP9Payloader_Payload(t *testing.T) {
 	for name, c := range cases {
 		pck := VP9Payloader{
 			InitialPictureIDFn: func() uint16 {
-				return uint16(rand.New(rand.NewSource(0)).Int31n(0x7FFF))
+				return uint16(rand.New(rand.NewSource(0)).Int31n(0x7FFF)) //nolint:gosec
 			},
 		}
 		c := c
@@ -276,7 +277,7 @@ func TestVP9Payloader_Payload(t *testing.T) {
 	t.Run("PictureIDOverflow", func(t *testing.T) {
 		pck := VP9Payloader{
 			InitialPictureIDFn: func() uint16 {
-				return uint16(rand.New(rand.NewSource(0)).Int31n(0x7FFF))
+				return uint16(rand.New(rand.NewSource(0)).Int31n(0x7FFF)) //nolint:gosec
 			},
 		}
 		pPrev := VP9Packet{}
diff --git a/packet_test.go b/packet_test.go
index add250d..f19e842 100644
--- a/packet_test.go
+++ b/packet_test.go
@@ -88,15 +88,16 @@ func TestExtension(t *testing.T) {
 		t.Fatal("Unmarshal did not error on packet with invalid extension length")
 	}
 
-	p = &Packet{Header: Header{
-		Extension:        true,
-		ExtensionProfile: 3,
-		Extensions: []Extension{
-			{0, []byte{
-				0,
-			}},
+	p = &Packet{
+		Header: Header{
+			Extension:        true,
+			ExtensionProfile: 3,
+			Extensions: []Extension{
+				{0, []byte{
+					0,
+				}},
+			},
 		},
-	},
 		Payload: []byte{},
 	}
 	if _, err := p.Marshal(); err == nil {
@@ -116,23 +117,24 @@ func TestRFC8285OneByteExtension(t *testing.T) {
 		t.Fatal("Unmarshal err for valid extension")
 	}
 
-	p = &Packet{Header: Header{
-		Marker:           true,
-		Extension:        true,
-		ExtensionProfile: 0xBEDE,
-		Extensions: []Extension{
-			{5, []byte{
-				0xAA,
-			}},
+	p = &Packet{
+		Header: Header{
+			Marker:           true,
+			Extension:        true,
+			ExtensionProfile: 0xBEDE,
+			Extensions: []Extension{
+				{5, []byte{
+					0xAA,
+				}},
+			},
+			Version:        2,
+			PayloadOffset:  18,
+			PayloadType:    96,
+			SequenceNumber: 27023,
+			Timestamp:      3653407706,
+			SSRC:           476325762,
+			CSRC:           []uint32{},
 		},
-		Version:        2,
-		PayloadOffset:  18,
-		PayloadType:    96,
-		SequenceNumber: 27023,
-		Timestamp:      3653407706,
-		SSRC:           476325762,
-		CSRC:           []uint32{},
-	},
 		Payload: rawPkt[20:],
 		Raw:     rawPkt,
 	}
@@ -176,26 +178,27 @@ func TestRFC8285OneByteTwoExtensionOfTwoBytes(t *testing.T) {
 	}
 
 	// Test Marshal
-	p = &Packet{Header: Header{
-		Marker:           true,
-		Extension:        true,
-		ExtensionProfile: 0xBEDE,
-		Extensions: []Extension{
-			{1, []byte{
-				0xAA,
-			}},
-			{2, []byte{
-				0xBB,
-			}},
+	p = &Packet{
+		Header: Header{
+			Marker:           true,
+			Extension:        true,
+			ExtensionProfile: 0xBEDE,
+			Extensions: []Extension{
+				{1, []byte{
+					0xAA,
+				}},
+				{2, []byte{
+					0xBB,
+				}},
+			},
+			Version:        2,
+			PayloadOffset:  26,
+			PayloadType:    96,
+			SequenceNumber: 27023,
+			Timestamp:      3653407706,
+			SSRC:           476325762,
+			CSRC:           []uint32{},
 		},
-		Version:        2,
-		PayloadOffset:  26,
-		PayloadType:    96,
-		SequenceNumber: 27023,
-		Timestamp:      3653407706,
-		SSRC:           476325762,
-		CSRC:           []uint32{},
-	},
 		Payload: rawPkt[20:],
 		Raw:     rawPkt,
 	}
@@ -297,29 +300,30 @@ func TestRFC8285OneByteMultipleExtensions(t *testing.T) {
 		0x98, 0x36, 0xbe, 0x88, 0x9e,
 	}
 
-	p := &Packet{Header: Header{
-		Marker:           true,
-		Extension:        true,
-		ExtensionProfile: 0xBEDE,
-		Extensions: []Extension{
-			{1, []byte{
-				0xAA,
-			}},
-			{2, []byte{
-				0xBB, 0xBB,
-			}},
-			{3, []byte{
-				0xCC, 0xCC, 0xCC, 0xCC,
-			}},
+	p := &Packet{
+		Header: Header{
+			Marker:           true,
+			Extension:        true,
+			ExtensionProfile: 0xBEDE,
+			Extensions: []Extension{
+				{1, []byte{
+					0xAA,
+				}},
+				{2, []byte{
+					0xBB, 0xBB,
+				}},
+				{3, []byte{
+					0xCC, 0xCC, 0xCC, 0xCC,
+				}},
+			},
+			Version:        2,
+			PayloadOffset:  26,
+			PayloadType:    96,
+			SequenceNumber: 27023,
+			Timestamp:      3653407706,
+			SSRC:           476325762,
+			CSRC:           []uint32{},
 		},
-		Version:        2,
-		PayloadOffset:  26,
-		PayloadType:    96,
-		SequenceNumber: 27023,
-		Timestamp:      3653407706,
-		SSRC:           476325762,
-		CSRC:           []uint32{},
-	},
 		Payload: rawPkt[28:],
 		Raw:     rawPkt,
 	}
@@ -344,25 +348,26 @@ func TestRFC8285TwoByteExtension(t *testing.T) {
 		t.Fatal("Unmarshal err for valid extension")
 	}
 
-	p = &Packet{Header: Header{
-		Marker:           true,
-		Extension:        true,
-		ExtensionProfile: 0x1000,
-		Extensions: []Extension{
-			{5, []byte{
-				0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
-				0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
-				0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
-			}},
+	p = &Packet{
+		Header: Header{
+			Marker:           true,
+			Extension:        true,
+			ExtensionProfile: 0x1000,
+			Extensions: []Extension{
+				{5, []byte{
+					0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
+					0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
+					0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
+				}},
+			},
+			Version:        2,
+			PayloadOffset:  42,
+			PayloadType:    96,
+			SequenceNumber: 27023,
+			Timestamp:      3653407706,
+			SSRC:           476325762,
+			CSRC:           []uint32{},
 		},
-		Version:        2,
-		PayloadOffset:  42,
-		PayloadType:    96,
-		SequenceNumber: 27023,
-		Timestamp:      3653407706,
-		SSRC:           476325762,
-		CSRC:           []uint32{},
-	},
 		Payload: rawPkt[44:],
 		Raw:     rawPkt,
 	}
@@ -443,28 +448,29 @@ func TestRFC8285TwoByteMultipleExtensionsWithLargeExtension(t *testing.T) {
 		0x98, 0x36, 0xbe, 0x88, 0x9e,
 	}
 
-	p := &Packet{Header: Header{
-		Marker:           true,
-		Extension:        true,
-		ExtensionProfile: 0x1000,
-		Extensions: []Extension{
-			{1, []byte{}},
-			{2, []byte{
-				0xBB,
-			}},
-			{3, []byte{
-				0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
-				0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
-			}},
+	p := &Packet{
+		Header: Header{
+			Marker:           true,
+			Extension:        true,
+			ExtensionProfile: 0x1000,
+			Extensions: []Extension{
+				{1, []byte{}},
+				{2, []byte{
+					0xBB,
+				}},
+				{3, []byte{
+					0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
+					0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
+				}},
+			},
+			Version:        2,
+			PayloadOffset:  40,
+			PayloadType:    96,
+			SequenceNumber: 27023,
+			Timestamp:      3653407706,
+			SSRC:           476325762,
+			CSRC:           []uint32{},
 		},
-		Version:        2,
-		PayloadOffset:  40,
-		PayloadType:    96,
-		SequenceNumber: 27023,
-		Timestamp:      3653407706,
-		SSRC:           476325762,
-		CSRC:           []uint32{},
-	},
 		Payload: rawPkt[40:],
 		Raw:     rawPkt,
 	}
@@ -480,17 +486,18 @@ func TestRFC8285GetExtensionReturnsNilWhenExtensionsDisabled(t *testing.T) {
 		// Payload
 		0x98, 0x36, 0xbe, 0x88, 0x9e,
 	}
-	p := &Packet{Header: Header{
-		Marker:         true,
-		Extension:      false,
-		Version:        2,
-		PayloadOffset:  26,
-		PayloadType:    96,
-		SequenceNumber: 27023,
-		Timestamp:      3653407706,
-		SSRC:           476325762,
-		CSRC:           []uint32{},
-	},
+	p := &Packet{
+		Header: Header{
+			Marker:         true,
+			Extension:      false,
+			Version:        2,
+			PayloadOffset:  26,
+			PayloadType:    96,
+			SequenceNumber: 27023,
+			Timestamp:      3653407706,
+			SSRC:           476325762,
+			CSRC:           []uint32{},
+		},
 		Payload: payload,
 	}
 
@@ -505,23 +512,24 @@ func TestRFC8285DelExtension(t *testing.T) {
 		// Payload
 		0x98, 0x36, 0xbe, 0x88, 0x9e,
 	}
-	p := &Packet{Header: Header{
-		Marker:           true,
-		Extension:        true,
-		ExtensionProfile: 0xBEDE,
-		Extensions: []Extension{
-			{1, []byte{
-				0xAA,
-			}},
+	p := &Packet{
+		Header: Header{
+			Marker:           true,
+			Extension:        true,
+			ExtensionProfile: 0xBEDE,
+			Extensions: []Extension{
+				{1, []byte{
+					0xAA,
+				}},
+			},
+			Version:        2,
+			PayloadOffset:  26,
+			PayloadType:    96,
+			SequenceNumber: 27023,
+			Timestamp:      3653407706,
+			SSRC:           476325762,
+			CSRC:           []uint32{},
 		},
-		Version:        2,
-		PayloadOffset:  26,
-		PayloadType:    96,
-		SequenceNumber: 27023,
-		Timestamp:      3653407706,
-		SSRC:           476325762,
-		CSRC:           []uint32{},
-	},
 		Payload: payload,
 	}
 
@@ -551,17 +559,18 @@ func TestRFC8285DelExtensionReturnsErrorWhenExtensionsDisabled(t *testing.T) {
 		// Payload
 		0x98, 0x36, 0xbe, 0x88, 0x9e,
 	}
-	p := &Packet{Header: Header{
-		Marker:         true,
-		Extension:      false,
-		Version:        2,
-		PayloadOffset:  26,
-		PayloadType:    96,
-		SequenceNumber: 27023,
-		Timestamp:      3653407706,
-		SSRC:           476325762,
-		CSRC:           []uint32{},
-	},
+	p := &Packet{
+		Header: Header{
+			Marker:         true,
+			Extension:      false,
+			Version:        2,
+			PayloadOffset:  26,
+			PayloadType:    96,
+			SequenceNumber: 27023,
+			Timestamp:      3653407706,
+			SSRC:           476325762,
+			CSRC:           []uint32{},
+		},
 		Payload: payload,
 	}
 
@@ -576,17 +585,18 @@ func TestRFC8285OneByteSetExtensionShouldEnableExensionsWhenAdding(t *testing.T)
 		// Payload
 		0x98, 0x36, 0xbe, 0x88, 0x9e,
 	}
-	p := &Packet{Header: Header{
-		Marker:         true,
-		Extension:      false,
-		Version:        2,
-		PayloadOffset:  26,
-		PayloadType:    96,
-		SequenceNumber: 27023,
-		Timestamp:      3653407706,
-		SSRC:           476325762,
-		CSRC:           []uint32{},
-	},
+	p := &Packet{
+		Header: Header{
+			Marker:         true,
+			Extension:      false,
+			Version:        2,
+			PayloadOffset:  26,
+			PayloadType:    96,
+			SequenceNumber: 27023,
+			Timestamp:      3653407706,
+			SSRC:           476325762,
+			CSRC:           []uint32{},
+		},
 		Payload: payload,
 	}
 
@@ -618,17 +628,18 @@ func TestRFC8285OneByteSetExtensionShouldSetCorrectExtensionProfileFor16ByteExte
 		// Payload
 		0x98, 0x36, 0xbe, 0x88, 0x9e,
 	}
-	p := &Packet{Header: Header{
-		Marker:         true,
-		Extension:      false,
-		Version:        2,
-		PayloadOffset:  26,
-		PayloadType:    96,
-		SequenceNumber: 27023,
-		Timestamp:      3653407706,
-		SSRC:           476325762,
-		CSRC:           []uint32{},
-	},
+	p := &Packet{
+		Header: Header{
+			Marker:         true,
+			Extension:      false,
+			Version:        2,
+			PayloadOffset:  26,
+			PayloadType:    96,
+			SequenceNumber: 27023,
+			Timestamp:      3653407706,
+			SSRC:           476325762,
+			CSRC:           []uint32{},
+		},
 		Payload: payload,
 	}
 
@@ -653,23 +664,24 @@ func TestRFC8285OneByteSetExtensionShouldUpdateExistingExension(t *testing.T) {
 		// Payload
 		0x98, 0x36, 0xbe, 0x88, 0x9e,
 	}
-	p := &Packet{Header: Header{
-		Marker:           true,
-		Extension:        true,
-		ExtensionProfile: 0xBEDE,
-		Extensions: []Extension{
-			{1, []byte{
-				0xAA,
-			}},
+	p := &Packet{
+		Header: Header{
+			Marker:           true,
+			Extension:        true,
+			ExtensionProfile: 0xBEDE,
+			Extensions: []Extension{
+				{1, []byte{
+					0xAA,
+				}},
+			},
+			Version:        2,
+			PayloadOffset:  26,
+			PayloadType:    96,
+			SequenceNumber: 27023,
+			Timestamp:      3653407706,
+			SSRC:           476325762,
+			CSRC:           []uint32{},
 		},
-		Version:        2,
-		PayloadOffset:  26,
-		PayloadType:    96,
-		SequenceNumber: 27023,
-		Timestamp:      3653407706,
-		SSRC:           476325762,
-		CSRC:           []uint32{},
-	},
 		Payload: payload,
 	}
 
@@ -693,23 +705,24 @@ func TestRFC8285OneByteSetExtensionShouldErrorWhenInvalidIDProvided(t *testing.T
 		// Payload
 		0x98, 0x36, 0xbe, 0x88, 0x9e,
 	}
-	p := &Packet{Header: Header{
-		Marker:           true,
-		Extension:        true,
-		ExtensionProfile: 0xBEDE,
-		Extensions: []Extension{
-			{1, []byte{
-				0xAA,
-			}},
+	p := &Packet{
+		Header: Header{
+			Marker:           true,
+			Extension:        true,
+			ExtensionProfile: 0xBEDE,
+			Extensions: []Extension{
+				{1, []byte{
+					0xAA,
+				}},
+			},
+			Version:        2,
+			PayloadOffset:  26,
+			PayloadType:    96,
+			SequenceNumber: 27023,
+			Timestamp:      3653407706,
+			SSRC:           476325762,
+			CSRC:           []uint32{},
 		},
-		Version:        2,
-		PayloadOffset:  26,
-		PayloadType:    96,
-		SequenceNumber: 27023,
-		Timestamp:      3653407706,
-		SSRC:           476325762,
-		CSRC:           []uint32{},
-	},
 		Payload: payload,
 	}
 
@@ -750,23 +763,24 @@ func TestRFC8285OneByteSetExtensionShouldErrorWhenPayloadTooLarge(t *testing.T)
 		// Payload
 		0x98, 0x36, 0xbe, 0x88, 0x9e,
 	}
-	p := &Packet{Header: Header{
-		Marker:           true,
-		Extension:        true,
-		ExtensionProfile: 0xBEDE,
-		Extensions: []Extension{
-			{1, []byte{
-				0xAA,
-			}},
+	p := &Packet{
+		Header: Header{
+			Marker:           true,
+			Extension:        true,
+			ExtensionProfile: 0xBEDE,
+			Extensions: []Extension{
+				{1, []byte{
+					0xAA,
+				}},
+			},
+			Version:        2,
+			PayloadOffset:  26,
+			PayloadType:    96,
+			SequenceNumber: 27023,
+			Timestamp:      3653407706,
+			SSRC:           476325762,
+			CSRC:           []uint32{},
 		},
-		Version:        2,
-		PayloadOffset:  26,
-		PayloadType:    96,
-		SequenceNumber: 27023,
-		Timestamp:      3653407706,
-		SSRC:           476325762,
-		CSRC:           []uint32{},
-	},
 		Payload: payload,
 	}
 
@@ -783,17 +797,18 @@ func TestRFC8285TwoByteSetExtensionShouldEnableExensionsWhenAdding(t *testing.T)
 		// Payload
 		0x98, 0x36, 0xbe, 0x88, 0x9e,
 	}
-	p := &Packet{Header: Header{
-		Marker:         true,
-		Extension:      false,
-		Version:        2,
-		PayloadOffset:  31,
-		PayloadType:    96,
-		SequenceNumber: 27023,
-		Timestamp:      3653407706,
-		SSRC:           476325762,
-		CSRC:           []uint32{},
-	},
+	p := &Packet{
+		Header: Header{
+			Marker:         true,
+			Extension:      false,
+			Version:        2,
+			PayloadOffset:  31,
+			PayloadType:    96,
+			SequenceNumber: 27023,
+			Timestamp:      3653407706,
+			SSRC:           476325762,
+			CSRC:           []uint32{},
+		},
 		Payload: payload,
 	}
 
@@ -828,23 +843,24 @@ func TestRFC8285TwoByteSetExtensionShouldUpdateExistingExension(t *testing.T) {
 		// Payload
 		0x98, 0x36, 0xbe, 0x88, 0x9e,
 	}
-	p := &Packet{Header: Header{
-		Marker:           true,
-		Extension:        true,
-		ExtensionProfile: 0x1000,
-		Extensions: []Extension{
-			{1, []byte{
-				0xAA,
-			}},
+	p := &Packet{
+		Header: Header{
+			Marker:           true,
+			Extension:        true,
+			ExtensionProfile: 0x1000,
+			Extensions: []Extension{
+				{1, []byte{
+					0xAA,
+				}},
+			},
+			Version:        2,
+			PayloadOffset:  26,
+			PayloadType:    96,
+			SequenceNumber: 27023,
+			Timestamp:      3653407706,
+			SSRC:           476325762,
+			CSRC:           []uint32{},
 		},
-		Version:        2,
-		PayloadOffset:  26,
-		PayloadType:    96,
-		SequenceNumber: 27023,
-		Timestamp:      3653407706,
-		SSRC:           476325762,
-		CSRC:           []uint32{},
-	},
 		Payload: payload,
 	}
 
@@ -871,23 +887,24 @@ func TestRFC8285TwoByteSetExtensionShouldErrorWhenPayloadTooLarge(t *testing.T)
 		// Payload
 		0x98, 0x36, 0xbe, 0x88, 0x9e,
 	}
-	p := &Packet{Header: Header{
-		Marker:           true,
-		Extension:        true,
-		ExtensionProfile: 0xBEDE,
-		Extensions: []Extension{
-			{1, []byte{
-				0xAA,
-			}},
+	p := &Packet{
+		Header: Header{
+			Marker:           true,
+			Extension:        true,
+			ExtensionProfile: 0xBEDE,
+			Extensions: []Extension{
+				{1, []byte{
+					0xAA,
+				}},
+			},
+			Version:        2,
+			PayloadOffset:  26,
+			PayloadType:    96,
+			SequenceNumber: 27023,
+			Timestamp:      3653407706,
+			SSRC:           476325762,
+			CSRC:           []uint32{},
 		},
-		Version:        2,
-		PayloadOffset:  26,
-		PayloadType:    96,
-		SequenceNumber: 27023,
-		Timestamp:      3653407706,
-		SSRC:           476325762,
-		CSRC:           []uint32{},
-	},
 		Payload: payload,
 	}
 
@@ -928,23 +945,24 @@ func TestRFC3550SetExtensionShouldErrorWhenNonZero(t *testing.T) {
 		// Payload
 		0x98, 0x36, 0xbe, 0x88, 0x9e,
 	}
-	p := &Packet{Header: Header{
-		Marker:           true,
-		Extension:        true,
-		ExtensionProfile: 0x1111,
-		Extensions: []Extension{
-			{0, []byte{
-				0xAA,
-			}},
+	p := &Packet{
+		Header: Header{
+			Marker:           true,
+			Extension:        true,
+			ExtensionProfile: 0x1111,
+			Extensions: []Extension{
+				{0, []byte{
+					0xAA,
+				}},
+			},
+			Version:        2,
+			PayloadOffset:  26,
+			PayloadType:    96,
+			SequenceNumber: 27023,
+			Timestamp:      3653407706,
+			SSRC:           476325762,
+			CSRC:           []uint32{},
 		},
-		Version:        2,
-		PayloadOffset:  26,
-		PayloadType:    96,
-		SequenceNumber: 27023,
-		Timestamp:      3653407706,
-		SSRC:           476325762,
-		CSRC:           []uint32{},
-	},
 		Payload: payload,
 	}
 
@@ -964,18 +982,19 @@ func TestRFC3550SetExtensionShouldRaiseErrorWhenSettingNonzeroID(t *testing.T) {
 		// Payload
 		0x98, 0x36, 0xbe, 0x88, 0x9e,
 	}
-	p := &Packet{Header: Header{
-		Marker:           true,
-		Extension:        true,
-		ExtensionProfile: 0x1111,
-		Version:          2,
-		PayloadOffset:    26,
-		PayloadType:      96,
-		SequenceNumber:   27023,
-		Timestamp:        3653407706,
-		SSRC:             476325762,
-		CSRC:             []uint32{},
-	},
+	p := &Packet{
+		Header: Header{
+			Marker:           true,
+			Extension:        true,
+			ExtensionProfile: 0x1111,
+			Version:          2,
+			PayloadOffset:    26,
+			PayloadType:      96,
+			SequenceNumber:   27023,
+			Timestamp:        3653407706,
+			SSRC:             476325762,
+			CSRC:             []uint32{},
+		},
 		Payload: payload,
 	}
 
diff --git a/packetizer_test.go b/packetizer_test.go
index cf57351..5d2331a 100644
--- a/packetizer_test.go
+++ b/packetizer_test.go
@@ -11,7 +11,7 @@ import (
 
 func TestPacketizer(t *testing.T) {
 	multiplepayload := make([]byte, 128)
-	//use the G722 payloader here, because it's very simple and all 0s is valid G722 data.
+	// use the G722 payloader here, because it's very simple and all 0s is valid G722 data.
 	packetizer := NewPacketizer(100, 98, 0x1234ABCD, &codecs.G722Payloader{}, NewRandomSequencer(), 90000)
 	packets := packetizer.Packetize(multiplepayload, 2000)
 
@@ -25,7 +25,7 @@ func TestPacketizer(t *testing.T) {
 }
 
 func TestPacketizer_AbsSendTime(t *testing.T) {
-	//use the G722 payloader here, because it's very simple and all 0s is valid G722 data.
+	// use the G722 payloader here, because it's very simple and all 0s is valid G722 data.
 	pktizer := NewPacketizer(100, 98, 0x1234ABCD, &codecs.G722Payloader{}, NewFixedSequencer(1234), 90000)
 	pktizer.(*packetizer).Timestamp = 45678
 	pktizer.(*packetizer).timegen = func() time.Time {
diff --git a/transportccextension_test.go b/transportccextension_test.go
index 11ed9df..5eb6967 100644
--- a/transportccextension_test.go
+++ b/transportccextension_test.go
@@ -2,6 +2,7 @@ package rtp
 
 import (
 	"bytes"
+	"errors"
 	"testing"
 )
 
@@ -10,7 +11,7 @@ func TestTransportCCExtensionTooSmall(t *testing.T) {
 
 	rawData := []byte{}
 
-	if err := t1.Unmarshal(rawData); err != errTooSmall {
+	if err := t1.Unmarshal(rawData); !errors.Is(err, errTooSmall) {
 		t.Fatal("err != errTooSmall")
 	}
 }