Skip to content

Commit 347c96e

Browse files
committed
fix golangci-lint reported problems
1 parent 9f40860 commit 347c96e

File tree

6 files changed

+13
-17
lines changed

6 files changed

+13
-17
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
- name: install golangci-lint and goveralls
3838
run: |
39-
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $GITHUB_WORKSPACE v1.41.1
39+
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $GITHUB_WORKSPACE v1.50.0
4040
GO111MODULE=off go get -u -v github.com/mattn/goveralls
4141
- name: run linters
4242
working-directory: backend

backend/.golangci.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,34 @@ run:
99
linters:
1010
enable:
1111
- bodyclose
12-
- deadcode
1312
- depguard
1413
- dogsled
1514
- dupl
16-
- gas
1715
- errcheck
16+
- exportloopref
17+
- gas
1818
- gochecknoinits
1919
- goconst
2020
- gocritic
2121
- gocyclo
2222
- gofmt
2323
- goimports
24-
- revive
2524
- goprintffuncname
26-
- gochecknoinits
2725
- gosec
2826
- gosimple
2927
- govet
3028
- ineffassign
31-
- misspell
3229
- megacheck
30+
- misspell
3331
- nakedret
32+
- revive
3433
- rowserrcheck
35-
- exportloopref
3634
- staticcheck
37-
- structcheck
3835
- stylecheck
3936
- typecheck
4037
- unconvert
4138
- unparam
4239
- unused
43-
- varcheck
40+
- unused
4441
- whitespace
4542
disable-all: true

backend/extractor/pics.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package extractor
22

33
import (
4-
"io/ioutil"
4+
"io"
55
"net/http"
66
"sort"
77
"sync"
@@ -78,7 +78,7 @@ func (f UReadability) getImageSize(url string) (size int) {
7878
}
7979
}()
8080

81-
data, err := ioutil.ReadAll(resp.Body)
81+
data, err := io.ReadAll(resp.Body)
8282
if err != nil {
8383
log.Printf("[WARN] failed to get %s, err=%v", url, err)
8484
return 0

backend/extractor/readability.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package extractor
44
import (
55
"context"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"net/http"
99
"net/url"
1010
"regexp"
@@ -84,7 +84,7 @@ func (f UReadability) Extract(ctx context.Context, reqURL string) (rb *Response,
8484
}()
8585

8686
rb.URL = resp.Request.URL.String()
87-
dataBytes, e := ioutil.ReadAll(resp.Body)
87+
dataBytes, e := io.ReadAll(resp.Body)
8888

8989
if e != nil {
9090
log.Printf("[WARN] failed to read data from %s, error=%v", reqURL, e)

backend/extractor/readability_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package extractor
33
import (
44
"context"
55
"io"
6-
"io/ioutil"
76
"log"
87
"net/http"
98
"net/http/httptest"
@@ -156,7 +155,7 @@ func TestGetContentCustom(t *testing.T) {
156155
resp, err := httpClient.Get("https://p.umputun.com/2015/09/25/poiezdka-s-apple-maps/")
157156
assert.NoError(t, err)
158157
defer resp.Body.Close()
159-
dataBytes, err := ioutil.ReadAll(resp.Body)
158+
dataBytes, err := io.ReadAll(resp.Body)
160159
assert.NoError(t, err)
161160
body := string(dataBytes)
162161

backend/extractor/text.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package extractor
22

33
import (
4-
"io/ioutil"
4+
"io"
55
"log"
66
"net/http"
77
"strings"
@@ -89,7 +89,7 @@ func (f UReadability) toUtf8(content []byte, header http.Header) (contentType, o
8989
log.Printf("[WARN] charset reader failed, %v", err)
9090
return contentType, origEncoding, result
9191
}
92-
conv2utf8, err := ioutil.ReadAll(rr)
92+
conv2utf8, err := io.ReadAll(rr)
9393
if err != nil {
9494
log.Printf("[WARN] convert to utf-8 failed, %b", err)
9595
return contentType, origEncoding, result

0 commit comments

Comments
 (0)