diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 0000000..e283ab9 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,26 @@ +name: golangci-lint +on: + push: + branches: + - main + - master + pull_request: + +permissions: + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` option. + # pull-requests: read + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: stable + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.60 diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..0291280 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,42 @@ +run: + timeout: 5m + issues-exit-code: 1 + tests: true + +issues: + max-same-issues: 100 + include: + - EXC0012 + - EXC0014 + exclude-dirs: [] + exclude-rules: + - path: retry_test.go + linters: + - revive + text: "this block is empty" + fix: true + +linters: + enable: + - bodyclose + - gofumpt + - goimports + - gosec + - gosimple + - govet + - ineffassign + - misspell + - revive + - staticcheck + - typecheck + - unused + - whitespace + +output: + formats: + - format: colored-line-number + print-issued-lines: true + print-linter-name: true + uniq-by-line: true + path-prefix: "" + sort-results: true \ No newline at end of file diff --git a/README.md b/README.md index d4d96ef..2623266 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,16 @@ +[![CI State](https://github.com/gotidy/iters/.github/workflows/go.yml/badge.svg)](https://github.com/gotidy/iters/actions) +[![Go Doc](https://godoc.org/github.com/gotidy/iters?status.svg)](https://pkg.go.dev/github.com/gotidy/iters) + # iters Go iterators. +## Installation + +```go +go get github.com/gotidy/iters +``` + ## General Iterators The `iters` library provides a set of general-purpose iterators that simplify the process of transformation, creation and using collections. diff --git a/iters.go b/iters.go index e1cddb2..bfb1ff2 100644 --- a/iters.go +++ b/iters.go @@ -308,7 +308,7 @@ func CountFunc[V any](s iter.Seq[V], f func(V) bool) int { return count } -// Count values. +// Count2 values. func Count2[K, V any](s iter.Seq2[K, V]) int { var count int for range s { @@ -425,7 +425,7 @@ func jitter[T constraints.Float | constraints.Integer](v T, factor, random float func Jitter[T constraints.Float | constraints.Integer](vv iter.Seq[T], factor float64) iter.Seq[T] { return func(yield func(T) bool) { jitter := func(v T) T { - return jitter(v, factor, float64(rand.Uint64())*2/math.MaxUint64-1) + return jitter(v, factor, float64(rand.Uint64())*2/math.MaxUint64-1) //nolint:gosec } if factor == 0 { jitter = func(v T) T { return v }