diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 4ce1ef5..bcd2fe5 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -8,20 +8,20 @@ jobs: name: lint runs-on: ubuntu-latest steps: - - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5 with: - go-version: 1.23 - - uses: actions/checkout@v3 + go-version: 1.26 + - uses: actions/checkout@v4 - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v7 with: - version: v1.60.3 + version: v2.10.1 args: --verbose test: strategy: matrix: - go-version: [1.23] + go-version: [1.26] platform: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.platform }} diff --git a/.golangci.yml b/.golangci.yml index 7ac922c..783fc74 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,72 +1,76 @@ -linters-settings: - errcheck: - check-type-assertions: true - goconst: - min-len: 2 - min-occurrences: 3 - gocritic: - enabled-tags: - - diagnostic - - experimental - - opinionated - - performance - - style - govet: - shadow: true - disable: - - fieldalignment # too strict +version: "2" + +run: + timeout: 5m + issues-exit-code: 1 - nolintlint: - require-explanation: false - require-specific: true linters: - disable-all: true enable: - - bodyclose - # - deadcode - # depguard needs to be reviewed properly and then configured, before - # it can be re-enabled. - # https://github.com/OpenPeeDeeP/depguard#example-configs - # - depguard - - copyloopvar - - dogsled - # - dupl + # correctness - errcheck - - exhaustive - - goconst - - gocritic - - gofmt - - goimports - - gocyclo - - gosec - - gosimple - govet + - staticcheck - ineffassign - - misspell - - mnd - - nolintlint - - nakedret + + # bug prevention + - copyloopvar + - bodyclose + - exhaustive + - unparam + - unconvert + + # code quality + # - gocyclo # TODO: enable later, need to fix complexity issues + - goconst + - revive - prealloc - predeclared - - revive - - staticcheck - # - structcheck - - stylecheck + + # security + - gosec + + # testing - thelper - tparallel - - unconvert - - unparam - # - varcheck + + # misc + - misspell - whitespace - - wsl + - nolintlint + - dogsled + + settings: + errcheck: + check-type-assertions: true + + goconst: + min-len: 2 + min-occurrences: 3 + + gocyclo: + min-complexity: 15 + + govet: + enable: + - shadow + + revive: + severity: warning + + nolintlint: + require-explanation: false + require-specific: true + + exclusions: + rules: + # Ginkgo/Gomega test suites use dot-imports by convention; suppress the + # revive dot-imports warning for all test files. + - path: '_test\.go' + linters: + - revive + text: 'dot-imports' issues: max-issues-per-linter: 0 max-same-issues: 0 - fix: true - exclude: - - "cuddle" - -run: - issues-exit-code: 1 - timeout: "5m" + fix: false diff --git a/.vscode/settings.json b/.vscode/settings.json index 4ebb94f..72a1e93 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,6 +8,7 @@ "astrolib", "Berthe", "bodyclose", + "chzyer", "Clonable", "cmds", "copyloopvar", @@ -41,13 +42,16 @@ "goveralls", "govet", "graffico", + "ianlancetaylor", "ineffassign", "jibberjabber", "leaktest", "linters", + "logr", "Malloc", "mattn", "nakedret", + "nefilim", "nicksnyder", "nolint", "nolintlint", diff --git a/doc.go b/doc.go new file mode 100644 index 0000000..76ab9d8 --- /dev/null +++ b/doc.go @@ -0,0 +1,3 @@ +// Package pants provides worker-pool abstractions and utilities +// for managing concurrent jobs and their results. +package pants diff --git a/examples/fp-throttled/doc.go b/examples/fp-throttled/doc.go new file mode 100644 index 0000000..b690e25 --- /dev/null +++ b/examples/fp-throttled/doc.go @@ -0,0 +1,3 @@ +// Package main provides an example func-based worker pool +// demonstrating throttled job submission and execution. +package main diff --git a/examples/fp-throttled/main.go b/examples/fp-throttled/main.go index b081801..3b6fe9b 100644 --- a/examples/fp-throttled/main.go +++ b/examples/fp-throttled/main.go @@ -1,3 +1,4 @@ +// Package main example program package main import ( diff --git a/examples/mf-all-output-consumed-by-range/doc.go b/examples/mf-all-output-consumed-by-range/doc.go new file mode 100644 index 0000000..82b8b5e --- /dev/null +++ b/examples/mf-all-output-consumed-by-range/doc.go @@ -0,0 +1,3 @@ +// Package main provides an example manifold-func worker pool +// where all output is consumed from an output channel. +package main diff --git a/examples/mf-all-output-consumed-by-range/main.go b/examples/mf-all-output-consumed-by-range/main.go index 54c318d..6a2ccdd 100644 --- a/examples/mf-all-output-consumed-by-range/main.go +++ b/examples/mf-all-output-consumed-by-range/main.go @@ -1,3 +1,4 @@ +// Package main example program package main import ( diff --git a/examples/mf-err-missing-consumer/doc.go b/examples/mf-err-missing-consumer/doc.go new file mode 100644 index 0000000..325fa47 --- /dev/null +++ b/examples/mf-err-missing-consumer/doc.go @@ -0,0 +1,3 @@ +// Package main provides an example manifold-func worker pool +// demonstrating timeout-on-send when there is no output consumer. +package main diff --git a/examples/mf-err-missing-consumer/main.go b/examples/mf-err-missing-consumer/main.go index 120e8fe..a008987 100644 --- a/examples/mf-err-missing-consumer/main.go +++ b/examples/mf-err-missing-consumer/main.go @@ -1,3 +1,4 @@ +// Package main example program package main import ( diff --git a/examples/mf-err-timeout-on-send/doc.go b/examples/mf-err-timeout-on-send/doc.go new file mode 100644 index 0000000..12f6070 --- /dev/null +++ b/examples/mf-err-timeout-on-send/doc.go @@ -0,0 +1,3 @@ +// Package main provides an example manifold-func worker pool +// demonstrating timeout-on-send behaviour. +package main diff --git a/examples/mf-err-timeout-on-send/main.go b/examples/mf-err-timeout-on-send/main.go index b928847..8a3d29d 100644 --- a/examples/mf-err-timeout-on-send/main.go +++ b/examples/mf-err-timeout-on-send/main.go @@ -1,3 +1,4 @@ +// Package main example program package main import ( diff --git a/examples/mf-input-injected-via-chan/doc.go b/examples/mf-input-injected-via-chan/doc.go new file mode 100644 index 0000000..a763ab5 --- /dev/null +++ b/examples/mf-input-injected-via-chan/doc.go @@ -0,0 +1,3 @@ +// Package main provides an example manifold-func worker pool +// where jobs are injected via an input channel. +package main diff --git a/examples/mf-input-injected-via-chan/main.go b/examples/mf-input-injected-via-chan/main.go index 33c980e..181f7a8 100644 --- a/examples/mf-input-injected-via-chan/main.go +++ b/examples/mf-input-injected-via-chan/main.go @@ -1,3 +1,4 @@ +// Package main example program package main import ( diff --git a/examples/tp-throttled/doc.go b/examples/tp-throttled/doc.go new file mode 100644 index 0000000..fad6efb --- /dev/null +++ b/examples/tp-throttled/doc.go @@ -0,0 +1,3 @@ +// Package main provides an example task pool +// demonstrating throttled job submission and execution. +package main diff --git a/examples/tp-throttled/main.go b/examples/tp-throttled/main.go index 42b891f..38ce3b2 100644 --- a/examples/tp-throttled/main.go +++ b/examples/tp-throttled/main.go @@ -1,3 +1,4 @@ +// Package main example program package main import ( diff --git a/go.mod b/go.mod index 43cd866..1fd6a23 100644 --- a/go.mod +++ b/go.mod @@ -1,27 +1,32 @@ module github.com/snivilised/pants -go 1.23.0 +go 1.26.0 require ( - github.com/nicksnyder/go-i18n/v2 v2.4.1 - github.com/onsi/ginkgo/v2 v2.22.1 - github.com/onsi/gomega v1.36.2 - github.com/snivilised/li18ngo v0.1.9 + github.com/nicksnyder/go-i18n/v2 v2.6.1 + github.com/onsi/ginkgo/v2 v2.28.1 + github.com/onsi/gomega v1.39.1 + github.com/snivilised/li18ngo v0.1.10 +) + +require ( + github.com/Masterminds/semver/v3 v3.4.0 // indirect + go.yaml.in/yaml/v3 v3.0.4 // indirect + golang.org/x/mod v0.33.0 // indirect + golang.org/x/sync v0.20.0 // indirect ) require ( github.com/fortytw2/leaktest v1.3.0 - github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/logr v1.4.3 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect - github.com/google/go-cmp v0.6.0 // indirect - github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect - github.com/kr/text v0.2.0 // indirect + github.com/google/go-cmp v0.7.0 // indirect + github.com/google/pprof v0.0.0-20260302011040-a15ffb7f9dcc // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/snivilised/nefilim v0.1.8 // indirect - golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect - golang.org/x/net v0.33.0 // indirect - golang.org/x/sys v0.28.0 // indirect - golang.org/x/text v0.21.0 // indirect - golang.org/x/tools v0.28.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect + github.com/snivilised/nefilim v0.1.11 // indirect + golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa // indirect + golang.org/x/net v0.51.0 // indirect + golang.org/x/sys v0.42.0 // indirect + golang.org/x/text v0.34.0 // indirect + golang.org/x/tools v0.42.0 // indirect ) diff --git a/go.sum b/go.sum index 1b5c2f1..6e6d285 100644 --- a/go.sum +++ b/go.sum @@ -1,52 +1,81 @@ -github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= -github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk= +github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= +github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0= +github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/gkampitakis/ciinfo v0.3.2 h1:JcuOPk8ZU7nZQjdUhctuhQofk7BGHuIy0c9Ez8BNhXs= +github.com/gkampitakis/ciinfo v0.3.2/go.mod h1:1NIwaOcFChN4fa/B0hEBdAb6npDlFL8Bwx4dfRLRqAo= +github.com/gkampitakis/go-diff v1.3.2 h1:Qyn0J9XJSDTgnsgHRdz9Zp24RaJeKMUHg2+PDZZdC4M= +github.com/gkampitakis/go-diff v1.3.2/go.mod h1:LLgOrpqleQe26cte8s36HTWcTmMEur6OPYerdAAS9tk= +github.com/gkampitakis/go-snaps v0.5.15 h1:amyJrvM1D33cPHwVrjo9jQxX8g/7E2wYdZ+01KS3zGE= +github.com/gkampitakis/go-snaps v0.5.15/go.mod h1:HNpx/9GoKisdhw9AFOBT1N7DBs9DiHo/hGheFGBZ+mc= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad h1:a6HEuzUHeKH6hwfN/ZoQgRgVIWFJljSWa/zetS2WTvg= -github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= +github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw= +github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/pprof v0.0.0-20260302011040-a15ffb7f9dcc h1:VBbFa1lDYWEeV5FZKUiYKYT0VxCp9twUmmaq9eb8sXw= +github.com/google/pprof v0.0.0-20260302011040-a15ffb7f9dcc/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI= +github.com/joshdk/go-junit v1.0.0 h1:S86cUKIdwBHWwA6xCmFlf3RTLfVXYQfvanM5Uh+K6GE= +github.com/joshdk/go-junit v1.0.0/go.mod h1:TiiV0PqkaNfFXjEiyjWM3XXrhVyCa1K4Zfga6W52ung= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/nicksnyder/go-i18n/v2 v2.4.1 h1:zwzjtX4uYyiaU02K5Ia3zSkpJZrByARkRB4V3YPrr0g= -github.com/nicksnyder/go-i18n/v2 v2.4.1/go.mod h1:++Pl70FR6Cki7hdzZRnEEqdc2dJt+SAGotyFg/SvZMk= -github.com/onsi/ginkgo/v2 v2.22.1 h1:QW7tbJAUDyVDVOM5dFa7qaybo+CRfR7bemlQUN6Z8aM= -github.com/onsi/ginkgo/v2 v2.22.1/go.mod h1:S6aTpoRsSq2cZOd+pssHAlKW/Q/jZt6cPrPlnj4a1xM= -github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8= -github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY= +github.com/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo= +github.com/maruel/natural v1.1.1/go.mod h1:v+Rfd79xlw1AgVBjbO0BEQmptqb5HvL/k9GRHB7ZKEg= +github.com/mfridman/tparse v0.18.0 h1:wh6dzOKaIwkUGyKgOntDW4liXSo37qg5AXbIhkMV3vE= +github.com/mfridman/tparse v0.18.0/go.mod h1:gEvqZTuCgEhPbYk/2lS3Kcxg1GmTxxU7kTC8DvP0i/A= +github.com/nicksnyder/go-i18n/v2 v2.6.1 h1:JDEJraFsQE17Dut9HFDHzCoAWGEQJom5s0TRd17NIEQ= +github.com/nicksnyder/go-i18n/v2 v2.6.1/go.mod h1:Vee0/9RD3Quc/NmwEjzzD7VTZ+Ir7QbXocrkhOzmUKA= +github.com/onsi/ginkgo/v2 v2.28.1 h1:S4hj+HbZp40fNKuLUQOYLDgZLwNUVn19N3Atb98NCyI= +github.com/onsi/ginkgo/v2 v2.28.1/go.mod h1:CLtbVInNckU3/+gC8LzkGUb9oF+e8W8TdUsxPwvdOgE= +github.com/onsi/gomega v1.39.1 h1:1IJLAad4zjPn2PsnhH70V4DKRFlrCzGBNrNaru+Vf28= +github.com/onsi/gomega v1.39.1/go.mod h1:hL6yVALoTOxeWudERyfppUcZXjMwIMLnuSfruD2lcfg= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= -github.com/snivilised/li18ngo v0.1.9 h1:xq+9yUv9JBY3fwzCzqCt0bIUdFlzDXcSjC2fQiSF3O0= -github.com/snivilised/li18ngo v0.1.9/go.mod h1:7soFZVy6K6P8jgHYn0fN2Sw0r66isPa/K/K+r3fl19Q= -github.com/snivilised/nefilim v0.1.8 h1:Srnl6rw7cB/cy3jQT8QfQ0ZNxumQX0Yj/Z+qH3+5TWc= -github.com/snivilised/nefilim v0.1.8/go.mod h1:xcQnPeB+zVD+xgw9yzy0QiMTGqjYNEWKeoaZL0TBQeA= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= +github.com/snivilised/li18ngo v0.1.10 h1:l0xiT278GdUjEmGIzUmM/UQ2/zlrVuc0kevmCU3Q4Qc= +github.com/snivilised/li18ngo v0.1.10/go.mod h1:+Oc4DADP9XISZEDZLiiG1WLonZo309Dj4e/zBcsNHNw= +github.com/snivilised/nefilim v0.1.11 h1:i8o4vb/4oNi6GVfTGUdUDqvINn8RyTmLdvVRW/aDu4A= +github.com/snivilised/nefilim v0.1.11/go.mod h1:1dQJlIcxLIl7iY3/DyL/52gSLEJoAmaB6sQTFF79Ofc= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY= -golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= -golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8= -golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw= -google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk= -google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= +github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= +go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= +golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa h1:Zt3DZoOFFYkKhDT3v7Lm9FDMEV06GpzjG2jrqW+QTE0= +golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa/go.mod h1:K79w1Vqn7PoiZn+TkNpx3BUWUQksGO3JcVX6qIjytmA= +golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8= +golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w= +golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo= +golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y= +golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4= +golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo= +golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk= +golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA= +golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k= +golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0= +google.golang.org/protobuf v1.36.7 h1:IgrO7UwFQGJdRNXH/sQux4R1Dj1WAKcLElzeeRaXV2A= +google.golang.org/protobuf v1.36.7/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/lab/doc.go b/internal/lab/doc.go new file mode 100644 index 0000000..92ce002 --- /dev/null +++ b/internal/lab/doc.go @@ -0,0 +1,3 @@ +// Package lab provides test utilities and helpers +// for integration tests and leak detection. +package lab diff --git a/internal/lab/test-utilities.go b/internal/lab/test-utilities.go index f6c621c..ec1edda 100644 --- a/internal/lab/test-utilities.go +++ b/internal/lab/test-utilities.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/fortytw2/leaktest" - . "github.com/onsi/ginkgo/v2" //nolint:stylecheck,revive // ok + . "github.com/onsi/ginkgo/v2" //nolint:staticcheck // ok ) func Path(parent, relative string) string { diff --git a/internal/third/ants/ants-suite_test.go b/internal/third/ants/ants-suite_test.go index ce2ce8e..ef940c1 100644 --- a/internal/third/ants/ants-suite_test.go +++ b/internal/third/ants/ants-suite_test.go @@ -3,8 +3,8 @@ package ants_test import ( "testing" - . "github.com/onsi/ginkgo/v2" //nolint:revive // ok - . "github.com/onsi/gomega" //nolint:revive // ok + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" ) func TestAnts(t *testing.T) { diff --git a/internal/third/ants/ants_test.go b/internal/third/ants/ants_test.go index 9ac7a5c..f867485 100644 --- a/internal/third/ants/ants_test.go +++ b/internal/third/ants/ants_test.go @@ -8,8 +8,8 @@ import ( "sync" "time" - . "github.com/onsi/ginkgo/v2" //nolint:revive // ok - . "github.com/onsi/gomega" //nolint:revive // ok + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" "github.com/snivilised/li18ngo" "github.com/snivilised/pants" diff --git a/internal/third/ants/async/doc.go b/internal/third/ants/async/doc.go new file mode 100644 index 0000000..34e3b81 --- /dev/null +++ b/internal/third/ants/async/doc.go @@ -0,0 +1,3 @@ +// Package async provides asynchronous synchronization primitives, +// including a spin lock implementation for lightweight locking. +package async diff --git a/internal/third/ants/default-options.go b/internal/third/ants/default-options.go index 715461e..5454500 100644 --- a/internal/third/ants/default-options.go +++ b/internal/third/ants/default-options.go @@ -20,7 +20,7 @@ const ( func init() { DefaultOutputOptions = &OutputOptions{ - BufferSize: uint(runtime.NumCPU()), + BufferSize: uint(runtime.NumCPU()), //nolint:gosec // G115 ok CheckCloseInterval: time.Second * scale, TimeoutOnSend: time.Second * scale, } diff --git a/internal/third/ants/doc.go b/internal/third/ants/doc.go new file mode 100644 index 0000000..b4f6e06 --- /dev/null +++ b/internal/third/ants/doc.go @@ -0,0 +1,3 @@ +// Package ants provides a high-performance goroutine pool implementation +// with configurable options for managing and reusing worker goroutines. +package ants diff --git a/internal/third/ants/options.go b/internal/third/ants/options.go index 85b573a..e670500 100644 --- a/internal/third/ants/options.go +++ b/internal/third/ants/options.go @@ -79,7 +79,7 @@ func withDefaults(options ...Option) []Option { WithGenerator(&Sequential{ Format: "ID:%08d", }), - WithSize(uint(runtime.NumCPU())), + WithSize(uint(runtime.NumCPU())), //nolint:gosec // G115 ok } o := make([]Option, 0, len(options)+len(defaults)) diff --git a/internal/third/ants/pool-func.go b/internal/third/ants/pool-func.go index e3a4e23..f2e2558 100644 --- a/internal/third/ants/pool-func.go +++ b/internal/third/ants/pool-func.go @@ -128,7 +128,7 @@ func (p *PoolWithFunc) goTicktock(ctx context.Context) { } func (p *PoolWithFunc) nowTime() time.Time { - return p.now.Load().(time.Time) + return p.now.Load().(time.Time) //nolint:errcheck // ok } // NewPoolWithFunc instantiates a PoolWithFunc with customized options. @@ -144,7 +144,7 @@ func NewPoolWithFunc(ctx context.Context, size := opts.Size if size == 0 { - size = uint(runtime.NumCPU()) + size = uint(runtime.NumCPU()) //nolint:gosec // G115 ok } if !opts.DisablePurge { diff --git a/internal/third/ants/pool.go b/internal/third/ants/pool.go index 8cbf9d4..c893e50 100644 --- a/internal/third/ants/pool.go +++ b/internal/third/ants/pool.go @@ -128,7 +128,7 @@ func (p *Pool) goTicktock(ctx context.Context) { } func (p *Pool) nowTime() time.Time { - return p.now.Load().(time.Time) + return p.now.Load().(time.Time) //nolint:errcheck // ok } // NewPool instantiates a Pool with customized options. @@ -137,7 +137,7 @@ func NewPool(ctx context.Context, options ...Option) (*Pool, error) { size := opts.Size if size == 0 { - size = uint(runtime.NumCPU()) + size = uint(runtime.NumCPU()) //nolint:gosec // G115 ok } if !opts.DisablePurge { diff --git a/internal/third/ants/support_test.go b/internal/third/ants/support_test.go index 8a7d00f..408fddf 100644 --- a/internal/third/ants/support_test.go +++ b/internal/third/ants/support_test.go @@ -5,7 +5,7 @@ import ( "sync/atomic" "time" - . "github.com/onsi/ginkgo/v2" //nolint:revive // ok + . "github.com/onsi/ginkgo/v2" "github.com/snivilised/pants" ) diff --git a/internal/third/lo/doc.go b/internal/third/lo/doc.go new file mode 100644 index 0000000..5ffb1fd --- /dev/null +++ b/internal/third/lo/doc.go @@ -0,0 +1,3 @@ +// Package lo provides generic helper types and utilities, +// including tuple-like structures and key/value entry definitions. +package lo diff --git a/locale/doc.go b/locale/doc.go new file mode 100644 index 0000000..e476ffa --- /dev/null +++ b/locale/doc.go @@ -0,0 +1,3 @@ +// Package locale provides localized messages, error strings, +// and template data for the pants module. +package locale diff --git a/locale/locale-suite_test.go b/locale/locale-suite_test.go index a529a2d..fe0b29d 100644 --- a/locale/locale-suite_test.go +++ b/locale/locale-suite_test.go @@ -3,8 +3,8 @@ package locale_test import ( "testing" - . "github.com/onsi/ginkgo/v2" //nolint:revive // ginkgo ok - . "github.com/onsi/gomega" //nolint:revive // gomega ok + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" ) func TestLocale(t *testing.T) { diff --git a/pants-suite_test.go b/pants-suite_test.go index 19bc33a..050b810 100644 --- a/pants-suite_test.go +++ b/pants-suite_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" - . "github.com/onsi/ginkgo/v2" //nolint:revive // ok - . "github.com/onsi/gomega" //nolint:revive // ok + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" "github.com/snivilised/pants" ) diff --git a/pool-defs-internal.go b/pool-defs-internal.go index 9d94799..75f032e 100644 --- a/pool-defs-internal.go +++ b/pool-defs-internal.go @@ -5,23 +5,12 @@ import ( ) const ( - // TODO: This is just temporary, channel size definition still needs to be + // DefaultChSize TODO: This is just temporary, channel size definition still needs to be // fine tuned - // DefaultChSize = 100 ) type ( - workerID string - workerFinishedResult struct { - id workerID - err error - } - - finishedStream = chan *workerFinishedResult - finishedStreamR = <-chan *workerFinishedResult - finishedStreamW = chan<- *workerFinishedResult - injectable[I any] interface { inject(input I) error } diff --git a/wait-group_test.go b/wait-group_test.go index db5a863..d271bda 100644 --- a/wait-group_test.go +++ b/wait-group_test.go @@ -6,8 +6,8 @@ import ( "sync" "time" - . "github.com/onsi/ginkgo/v2" //nolint:revive // ginkgo ok - . "github.com/onsi/gomega" //nolint:revive // gomega ok + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" "github.com/snivilised/li18ngo" "github.com/snivilised/pants" diff --git a/worker-pool-func-manifold.go b/worker-pool-func-manifold.go index 4e885ec..68898fa 100644 --- a/worker-pool-func-manifold.go +++ b/worker-pool-func-manifold.go @@ -77,7 +77,7 @@ func (p *ManifoldFuncPool[I, O]) Source(ctx context.Context, ) SourceStreamW[I] { o := p.pool.GetOptions() - p.basePool.inputDupCh = source(ctx, wg, o, + p.inputDupCh = source(ctx, wg, o, injector[I](func(input I) error { return p.Post(ctx, input) }), @@ -86,7 +86,7 @@ func (p *ManifoldFuncPool[I, O]) Source(ctx context.Context, }), ) - return p.basePool.inputDupCh.WriterCh + return p.inputDupCh.WriterCh } // Conclude signifies to the worker pool that no more work will be diff --git a/worker-pool-func-manifold_test.go b/worker-pool-func-manifold_test.go index 5b2448e..a1e0808 100644 --- a/worker-pool-func-manifold_test.go +++ b/worker-pool-func-manifold_test.go @@ -9,8 +9,8 @@ import ( "sync" "time" - . "github.com/onsi/ginkgo/v2" //nolint:revive // ginkgo ok - . "github.com/onsi/gomega" //nolint:revive // gomega ok + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" "github.com/snivilised/li18ngo" "github.com/snivilised/pants" diff --git a/worker-pool-func.go b/worker-pool-func.go index 5235906..0b87dad 100644 --- a/worker-pool-func.go +++ b/worker-pool-func.go @@ -9,7 +9,6 @@ import ( type FuncPool[I, O any] struct { basePool[I, O] functionalPool - sourceJobsChIn JobStream[I] } // NewFuncPool creates a new worker pool using the native ants interface; ie diff --git a/worker-pool-func_test.go b/worker-pool-func_test.go index acba3fa..04645d8 100644 --- a/worker-pool-func_test.go +++ b/worker-pool-func_test.go @@ -7,8 +7,8 @@ import ( "sync" "time" - . "github.com/onsi/ginkgo/v2" //nolint:revive // ginkgo ok - . "github.com/onsi/gomega" //nolint:revive // gomega ok + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" "github.com/snivilised/li18ngo" "github.com/snivilised/pants" diff --git a/worker-pool-task.go b/worker-pool-task.go index a028004..e33978c 100644 --- a/worker-pool-task.go +++ b/worker-pool-task.go @@ -31,7 +31,6 @@ import ( type TaskPool[I, O any] struct { basePool[I, O] taskPool - sourceJobsChIn JobStream[I] } // NewTaskPool creates a new worker pool using the native ants interface; ie diff --git a/worker-pool-task_test.go b/worker-pool-task_test.go index c17ade8..093f899 100644 --- a/worker-pool-task_test.go +++ b/worker-pool-task_test.go @@ -7,8 +7,8 @@ import ( "sync" "time" - . "github.com/onsi/ginkgo/v2" //nolint:revive // ginkgo ok - . "github.com/onsi/gomega" //nolint:revive // gomega ok + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" "github.com/snivilised/li18ngo" "github.com/snivilised/pants"