From 3ca71f67c04ef20854949635c377d8b87c74d8ad Mon Sep 17 00:00:00 2001 From: Khanh Hoa Date: Sat, 21 Sep 2024 16:59:21 +0700 Subject: [PATCH 1/2] feat: add github workflows --- .github/dependabot.yml | 15 +++++++++++++++ .github/workflows/golangci.yml | 27 +++++++++++++++++++++++++++ .github/workflows/test.yml | 22 ++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/golangci.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..1809840 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "github-actions" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" + - package-ecosystem: "gomod" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" \ No newline at end of file diff --git a/.github/workflows/golangci.yml b/.github/workflows/golangci.yml new file mode 100644 index 0000000..a5e5943 --- /dev/null +++ b/.github/workflows/golangci.yml @@ -0,0 +1,27 @@ +name: golangci-lint +on: + push: + tags: + - v* + branches: + - master + - main + 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/setup-go@v5 + with: + go-version: "1.23.1" + - uses: actions/checkout@v4 + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: latest + args: --timeout 10m \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..c380e1b --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,22 @@ +name: test + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + run-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.23.1" + + - name: Test + run: go test --race -v ./... \ No newline at end of file From 864cbb248678b10424b6a522ceefa98f8c61e58f Mon Sep 17 00:00:00 2001 From: Khanh Hoa Date: Sat, 21 Sep 2024 17:02:40 +0700 Subject: [PATCH 2/2] handle panic --- pool.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pool.go b/pool.go index b619a5e..4335b53 100644 --- a/pool.go +++ b/pool.go @@ -31,6 +31,8 @@ func FromConcPool(p *conc.Pool) Pool { func FromAntsPool(p *ants.Pool) Pool { return wrapFunc(func(f func()) { - p.Submit(f) + if err := p.Submit(f); err != nil { + panic(err) + } }) }