diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12e210868..18a019fa5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,10 +31,10 @@ jobs: - name: Test run: | - go install golang.org/x/lint/golint@latest + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2 OUT="$(go get -a)"; test -z "$OUT" || (echo "$OUT" && return 1) OUT="$(gofmt -l -d ./)"; test -z "$OUT" || (echo "$OUT" && return 1) - golint -set_exit_status + golangci-lint run go vet -v ./... go test -race -v -coverprofile=coverage.txt -covermode=atomic ./... @@ -62,18 +62,18 @@ jobs: - name: Build run: | - go install golang.org/x/lint/golint@latest + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2 OUT="$(go get -a)"; test -z "$OUT" || (echo "$OUT" && return 1) OUT="$(gofmt -l -d ./)"; test -z "$OUT" || (echo "$OUT" && return 1) - golint -set_exit_status + golangci-lint run go build codecov: - name: Codecov + name: Codecov runs-on: [ubuntu-latest] - needs: + needs: - test - build steps: - - name: Run Codecov + - name: Run Codecov run: bash <(curl -s https://codecov.io/bash) diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 000000000..c5671d98f --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,3 @@ +run: + skip-files: + - ".*\\_test\\.go$" diff --git a/cmd/colly/colly.go b/cmd/colly/colly.go index a8e626fd3..a460eaaa7 100644 --- a/cmd/colly/colly.go +++ b/cmd/colly/colly.go @@ -113,9 +113,9 @@ func main() { } } scraper.WriteString(scraperEndTemplate) - outfile.Write(scraper.Bytes()) + _, _ = outfile.Write(scraper.Bytes()) } }) - app.Run(os.Args) + _ = app.Run(os.Args) } diff --git a/colly.go b/colly.go index fdca94518..c5eacc6d0 100644 --- a/colly.go +++ b/colly.go @@ -450,7 +450,7 @@ func DetectCharset() CollectorOption { // Debugger sets the debugger used by the Collector. func Debugger(d debug.Debugger) CollectorOption { return func(c *Collector) { - d.Init() + _ = d.Init() c.debugger = d } } @@ -470,7 +470,7 @@ func (c *Collector) Init() { c.MaxDepth = 0 c.MaxRequests = 0 c.store = &storage.InMemoryStorage{} - c.store.Init() + _ = c.store.Init() c.MaxBodySize = 10 * 1024 * 1024 c.backend = &httpBackend{} jar, _ := cookiejar.New(nil) @@ -573,7 +573,7 @@ func (c *Collector) Request(method, URL string, requestData io.Reader, ctx *Cont // SetDebugger attaches a debugger to the collector func (c *Collector) SetDebugger(d debug.Debugger) { - d.Init() + _ = d.Init() c.debugger = d } @@ -648,6 +648,7 @@ func (c *Collector) scrape(u, method string, depth int, requestData io.Reader, c u = parsedURL.String() c.wg.Add(1) if c.Async { + // nolint:errcheck go c.fetch(u, method, depth, requestData, ctx, hdr, req) return nil } @@ -720,12 +721,12 @@ func (c *Collector) fetch(u, method string, depth int, requestData io.Reader, ct err = c.handleOnHTML(response) if err != nil { - c.handleOnError(response, err, request, ctx) + _ = c.handleOnError(response, err, request, ctx) } err = c.handleOnXML(response) if err != nil { - c.handleOnError(response, err, request, ctx) + _ = c.handleOnError(response, err, request, ctx) } c.handleOnScraped(response) @@ -1523,9 +1524,9 @@ func requestHash(url string, body io.Reader) uint64 { h := fnv.New64a() // reparse the url to fix ambiguities such as // "http://example.com" vs "http://example.com/" - io.WriteString(h, normalizeURL(url)) + _, _ = io.WriteString(h, normalizeURL(url)) if body != nil { - io.Copy(h, body) + _, _ = io.Copy(h, body) } return h.Sum64() } diff --git a/debug/webdebugger.go b/debug/webdebugger.go index 504a9eb04..bf7bdc783 100644 --- a/debug/webdebugger.go +++ b/debug/webdebugger.go @@ -57,6 +57,7 @@ func (w *WebDebugger) Init() error { http.HandleFunc("/", w.indexHandler) http.HandleFunc("/status", w.statusHandler) log.Println("Starting debug webserver on", w.Address) + // nolint:errcheck go http.ListenAndServe(w.Address, nil) return nil } @@ -84,7 +85,7 @@ func (w *WebDebugger) Event(e *Event) { } func (w *WebDebugger) indexHandler(wr http.ResponseWriter, r *http.Request) { - wr.Write([]byte(` + _, _ = wr.Write([]byte(`