Skip to content

Commit 38f3a28

Browse files
committed
ignore errcheck lint
1 parent 4effa5e commit 38f3a28

File tree

6 files changed

+28
-14
lines changed

6 files changed

+28
-14
lines changed

.golangci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: "2"
2+
3+
linters-settings:
4+
errcheck:
5+
# Don't check for Close() errors in defers
6+
exclude-functions:
7+
- '(net/http).(*Response).Body.Close'
8+
- "(database/sql).(*Rows).Close"
9+
- "(os).Remove"
10+
- "(os).RemoveAll"
11+
- "(*os.File).Close"
12+
- "(*bytes.Reader).Close"
13+
- "(*io.PipeWriter).Close"
14+
- "(io.ReadCloser).Close"

balancer/catabalancer/catalyst_balancer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ func (c *CataBalancer) refreshNodes(ctx context.Context) (stats, error) {
339339
if err != nil {
340340
return s, fmt.Errorf("failed to query node stats: %w", err)
341341
}
342-
defer rows.Close()
342+
defer rows.Close() // nolint:errcheck
343343

344344
// Process the result set
345345
for rows.Next() {

balancer/mist/mist_balancer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func (b *MistBalancer) changeLoadBalancerServers(ctx context.Context, server, ac
176176
glog.Errorf("Error making request: %v", err)
177177
return nil, err
178178
}
179-
defer resp.Body.Close()
179+
defer resp.Body.Close() // nolint:errcheck
180180

181181
bytes, err := io.ReadAll(resp.Body)
182182

@@ -212,7 +212,7 @@ func (b *MistBalancer) getMistLoadBalancerServers(ctx context.Context) (map[stri
212212
glog.Errorf("Error making request: %v", err)
213213
return nil, err
214214
}
215-
defer resp.Body.Close()
215+
defer resp.Body.Close() // nolint:errcheck
216216

217217
if resp.StatusCode != http.StatusOK {
218218
b, _ := io.ReadAll(resp.Body)
@@ -473,7 +473,7 @@ func (b *MistBalancer) mistUtilLoadRequest(ctx context.Context, route, stream, l
473473
if err != nil {
474474
return "", err
475475
}
476-
defer resp.Body.Close()
476+
defer resp.Body.Close() // nolint:errcheck
477477

478478
if resp.StatusCode != http.StatusOK {
479479
return "", fmt.Errorf("GET request '%s' failed with http status code %d", murl, resp.StatusCode)

c2pa/c2pa_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestSign(t *testing.T) {
1919

2020
outFile := "test/tiny_output_signed.mp4"
2121
c := NewC2PA("es256", "test/es256_private.key", "test/es256_certs.pem")
22-
defer os.Remove(outFile)
22+
defer os.Remove(outFile) // nolint:errcheck
2323

2424
err = c.SignFile("test/tiny.mp4", outFile, "Tiny", "")
2525

@@ -38,7 +38,7 @@ func TestSignWithParent(t *testing.T) {
3838

3939
outFile := "test/tiny_cut_output_signed.mp4"
4040
c := NewC2PA("es256", "test/es256_private.key", "test/es256_certs.pem")
41-
defer os.Remove(outFile)
41+
defer os.Remove(outFile) // nolint:errcheck
4242

4343
err = c.SignFile("test/tiny_cut.mp4", outFile, "Tiny", "test/tiny_signed.mp4")
4444

clients/broadcaster_remote.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func findBroadcaster(c Credentials) (BroadcasterList, error) {
8484
if err != nil {
8585
return BroadcasterList{}, fmt.Errorf("http do(%s): %v", requestURL, err)
8686
}
87-
defer res.Body.Close()
87+
defer res.Body.Close() // nolint:errcheck
8888

8989
if !httpOk(res.StatusCode) {
9090
return BroadcasterList{}, fmt.Errorf("http GET(%s) returned %d %s", requestURL, res.StatusCode, res.Status)
@@ -130,7 +130,7 @@ func CreateStream(c Credentials, streamName string, profiles []video.EncodedProf
130130
if err != nil {
131131
return "", fmt.Errorf("http do(%s): %v", requestURL, err)
132132
}
133-
defer res.Body.Close()
133+
defer res.Body.Close() // nolint:errcheck
134134

135135
if !httpOk(res.StatusCode) {
136136
return "", fmt.Errorf("http POST(%s) returned %d %s", requestURL, res.StatusCode, res.Status)
@@ -164,7 +164,7 @@ func ReleaseManifestID(c Credentials, manifestId string) error {
164164
if err != nil {
165165
return fmt.Errorf("Releasing Manifest ID failed. URL: %s, manifestID: %s, err: %s", requestURL, manifestId, err)
166166
}
167-
defer res.Body.Close()
167+
defer res.Body.Close() // nolint:errcheck
168168

169169
if !httpOk(res.StatusCode) {
170170
return fmt.Errorf("Releasing Manifest ID failed. URL: %s, manifestID: %s, HTTP Code: %s", requestURL, manifestId, res.Status)

clients/manifest.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func RecordingBackupCheck(requestID string, primaryManifestURL, osTransferURL *u
7777
var rc io.ReadCloser
7878
rc, actualSegURL, err = GetFileWithBackup(context.Background(), requestID, segURL.String(), dStorage)
7979
if rc != nil {
80-
rc.Close()
80+
rc.Close() // nolint:errcheck
8181
}
8282
return err
8383
}, DownloadRetryBackoff())
@@ -189,7 +189,7 @@ func downloadManifest(requestID, sourceManifestOSURL string) (playlist m3u8.Play
189189
}
190190
return err
191191
}
192-
defer rc.Close()
192+
defer rc.Close() // nolint:errcheck
193193

194194
data := new(bytes.Buffer)
195195
_, err = data.ReadFrom(rc)
@@ -390,7 +390,7 @@ func ClipInputManifest(requestID, sourceURL, clipTargetUrl string, startTimeUnix
390390
if err != nil {
391391
return nil, fmt.Errorf("error clipping: failed to create temp clipping storage dir: %w", err)
392392
}
393-
defer os.RemoveAll(clipStorageDir)
393+
defer os.RemoveAll(clipStorageDir) // nolint:errcheck
394394

395395
// Download start/end segments and clip
396396
for i, v := range segsToClip {
@@ -451,7 +451,7 @@ func ClipInputManifest(requestID, sourceURL, clipTargetUrl string, startTimeUnix
451451
if err != nil {
452452
return nil, fmt.Errorf("error clipping: failed to open clipped segment %d: %w", v.SeqId, err)
453453
}
454-
defer clippedSegmentFile.Close()
454+
defer clippedSegmentFile.Close() // nolint:errcheck
455455

456456
clippedSegmentOSFilename := "clip_" + strconv.FormatUint(v.SeqId, 10) + ".ts"
457457
err = UploadToOSURL(clipTargetUrl, clippedSegmentOSFilename, clippedSegmentFile, MaxCopyFileDuration)
@@ -553,7 +553,7 @@ func GetFirstRenditionURL(requestID string, masterManifestURL *url.URL) (*url.UR
553553
if err != nil {
554554
return fmt.Errorf("error downloading manifest %s: %w", masterManifestURL.Redacted(), err)
555555
}
556-
defer rc.Close()
556+
defer rc.Close() // nolint:errcheck
557557

558558
playlist, playlistType, err = m3u8.DecodeFrom(rc, true)
559559
if err != nil {

0 commit comments

Comments
 (0)