From b6b857b3185c47e2441beca0f95f607c97d5d3c7 Mon Sep 17 00:00:00 2001 From: Axel Etcheverry Date: Mon, 29 Jan 2024 23:58:53 +0100 Subject: [PATCH] feat: update golangci-lint --- .github/workflows/go.yml | 2 +- .golangci.yml | 96 +++++++++++++++++++++++++++++++++++----- default.go | 4 +- future.go | 14 +++--- 4 files changed, 94 insertions(+), 22 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 94db976..3e0ea96 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -141,7 +141,7 @@ jobs: - name: Run golangci-lint uses: golangci/golangci-lint-action@v3.7.0 with: - version: v1.52.2 + version: v1.55.2 skip-pkg-cache: true - name: Coveralls diff --git a/.golangci.yml b/.golangci.yml index de5c1a7..d7a5e5f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,13 +1,85 @@ -run: - concurrency: 4 - deadline: 3m - issues-exit-code: 1 - tests: false - skip-files: - - ".*_mock\\.go" - - "mock_.*\\.go" - +linters: + disable-all: true + enable: + - errcheck + - gas + - goconst + - gocyclo + - gofmt + - revive + - govet + - ineffassign + - megacheck + - misspell + - typecheck + - unconvert + - gosimple + - staticcheck + - unused + - asciicheck + - bodyclose + - dogsled + - durationcheck + - errorlint + - exhaustive + - exportloopref + - forbidigo + - forcetypeassert + - gocritic + - godot + - gosec + - nestif + - nilerr + - nlreturn + - noctx + - prealloc + - predeclared + - sqlclosecheck + - whitespace + - wrapcheck + - wsl + fast: false +linters-settings: + depguard: + rules: + main: + allow: + - $all + dupl: + threshold: 99 + errcheck: + check-blank: false + check-type-assertions: false + goconst: + min-len: 3 + min-occurrences: 2 + gocyclo: + min-complexity: 18 + gofmt: + simplify: true + goimports: + local-prefixes: go.opentelemetry.io + govet: + check-shadowing: false + maligned: + suggest-new: true + misspell: + ignore-words: + - cancelled + locale: US + revive: + ignore-generated-header: true + severity: warning output: - format: colored-line-number - print-issued-lines: true - print-linter-name: true + format: colored-line-number + print-issued-lines: true + print-linter-name: true +run: + concurrency: 4 + issues-exit-code: 1 + skip-files: + - .*_mock\.go + - mock_.*\.go + - .*/pkg/mod/.*$ + tests: false + timeout: 1m diff --git a/default.go b/default.go index 89631b7..0675f04 100644 --- a/default.go +++ b/default.go @@ -4,12 +4,12 @@ package future -// Error return future error +// Error return future error. func Error(err error) *Future { return New().Error(err) } -// Value return future value +// Value return future value. func Value(value interface{}) *Future { return New().Value(value) } diff --git a/future.go b/future.go index ee20663..0dac20a 100644 --- a/future.go +++ b/future.go @@ -9,21 +9,21 @@ import ( "reflect" ) -// Future struct +// Future struct. type Future struct { err error value chan interface{} closed bool } -// New Future +// New Future. func New() *Future { return &Future{ value: make(chan interface{}, 1), } } -// Error set error to Future +// Error set error to Future. func (f *Future) Error(err error) *Future { f.err = err @@ -32,7 +32,7 @@ func (f *Future) Error(err error) *Future { return f } -// Value set value to Future +// Value set value to Future. func (f *Future) Value(value interface{}) *Future { if !f.closed { f.value <- value @@ -41,7 +41,7 @@ func (f *Future) Value(value interface{}) *Future { return f } -// Get result or error +// Get result or error. func (f *Future) Get() (interface{}, error) { value := <-f.value @@ -54,7 +54,7 @@ func (f *Future) Get() (interface{}, error) { return value, nil } -// Close future +// Close future. func (f *Future) Close() { if !f.closed { f.closed = true @@ -63,7 +63,7 @@ func (f *Future) Close() { } } -// Fill dest var +// Fill dest var. func (f *Future) Fill(dest interface{}) error { value := <-f.value