ants Documentation

Ants is the most powerful and reliable pooling solution for Go.

14,527 stars Go Go 1 file ยท ~9,806 tokens #ants#go#goroutine#goroutine-pool#pool#worker-pool
RAW Doc

File: README.md

English | ไธญๆ–‡

๐Ÿ“– Introduction

Library ants implements a goroutine pool with fixed capacity, managing and recycling a massive number of goroutines, allowing developers to limit the number of goroutines in your concurrent programs.

๐Ÿš€ Features:

  • Managing and recycling a massive number of goroutines automatically
  • Purging overdue goroutines periodically
  • Abundant APIs: submitting tasks, getting the number of running goroutines, tuning the capacity of the pool dynamically, releasing the pool, rebooting the pool, etc.
  • Handle panic gracefully to prevent programs from crash
  • Efficientย inย memoryย usage and it may even achieveย higher performanceย than unlimited goroutines in Go
  • Nonblocking mechanism
  • Preallocated memory (ring buffer, optional)

๐Ÿ’ก How `ants` works

Flow Diagram

Activity Diagrams

๐Ÿงฐ How to install

For `ants` v1

powershell
go get -u github.com/panjf2000/ants

For `ants` v2 (with GO111MODULE=on)

powershell
go get -u github.com/panjf2000/ants/v2

๐Ÿ›  How to use

Check out the examples for basic usage.

Functional options for pool

ants.Optionscontains all optional configurations of the ants pool, which allows you to customize the goroutine pool by invoking option functions to set up each configuration in NewPool/NewPoolWithFunc/NewPoolWithFuncGeneric method.

Check out ants.Options and ants.Option for more details.

Customize pool capacity

ants supports customizing the capacity of the pool. You can call the NewPool method to instantiate a Pool with a given capacity, as follows:

go
p, _ := ants.NewPool(10000)

Submit tasks

Tasks can be submitted by calling ants.Submit

go
ants.Submit(func(){})

Tune pool capacity at runtime

You can tune the capacity of ants pool at runtime with ants.Tune:

go
pool.Tune(1000) // Tune its capacity to 1000
pool.Tune(100000) // Tune its capacity to 100000

Don't worry about the contention problems in this case, the method here is thread-safe (or should be called goroutine-safe).

Pre-malloc goroutine queue in pool

ants allows you to pre-allocate the memory of the goroutine queue in the pool, which may get a performance enhancement under some special certain circumstances such as the scenario that requires a pool with ultra-large capacity, meanwhile, each task in goroutine lasts for a long time, in this case, pre-mallocing will reduce a lot of memory allocation in goroutine queue.

go
// ants will pre-malloc the whole capacity of pool when calling ants.NewPool.
p, _ := ants.NewPool(100000, ants.WithPreAlloc(true))

Release pool

go
pool.Release()

or

go
pool.ReleaseTimeout(time.Second * 3)

Reboot pool

go
// A pool that has been released can be still used after calling the Reboot().
pool.Reboot()

โš™๏ธ About sequence

All tasks submitted to ants pool will not be guaranteed to be addressed in order, because those tasks scatter among a series of concurrent workers, thus those tasks would be executed concurrently.

๐Ÿ‘ Contributors

Please read our Contributing Guidelines before opening a PR and thank you to all the developers who already made contributions to ants!

๐Ÿ“„ License

The source code in ants is available under the MIT License.

๐Ÿ“š Relevant Articles

๐Ÿ–ฅ Use cases

business corporations & open-source organizations

Trusted by the following corporations/organizations.

If you're also using ants in production, please help us enrich this list by opening a pull request.

open-source software

The open-source projects below do concurrent programming with the help of ants.

  • gnet: A high-performance, lightweight, non-blocking, event-driven networking framework written in pure Go.
  • milvus: An open-source vector database for scalable similarity search and AI applications.
  • nps: A lightweight, high-performance, powerful intranet penetration proxy server, with a powerful web management terminal.
  • TDengine: TDengine is an open source, high-performance, cloud native time-series database optimized for Internet of Things (IoT), Connected Cars, and Industrial IoT.
  • siyuan: SiYuan is a local-first personal knowledge management system that supports complete offline use, as well as end-to-end encrypted synchronization.
  • BillionMail: A future open-source Mail server, Email marketing platform designed to help businesses and individuals manage their email campaigns with ease.
  • WeKnora: An LLM-powered framework designed for deep document understanding and semantic retrieval, especially for handling complex, heterogeneous documents.
  • coze-loop: A developer-oriented, platform-level solution focused on the development and operation of AI agents.
  • osmedeus: A Workflow Engine for Offensive Security.
  • jitsu: An open-source Segment alternative. Fully-scriptable data ingestion engine for modern data teams. Set-up a real-time data pipeline in minutes, not days.
  • triangula: Generate high-quality triangulated and polygonal art from images.
  • teler: Real-time HTTP Intrusion Detection.
  • bsc: A Binance Smart Chain client based on the go-ethereum fork.
  • jaeles: The Swiss Army knife for automated Web Application Testing.
  • devlake: The open-source dev data platform & dashboard for your DevOps tools.
  • matrixone: MatrixOne is a future-oriented hyper-converged cloud and edge native DBMS that supports transactional, analytical, and streaming workloads with a simplified and distributed database engine, across multiple data centers, clouds, edges and other heterogeneous infrastructures.
  • bk-bcs: BlueKing Container Service (BCS, same below) is a container management and orchestration platform for the micro-services under the BlueKing ecosystem.
  • trueblocks-core: TrueBlocks improves access to blockchain data for any EVM-compatible chain (particularly Ethereum mainnet) while remaining entirely local.
  • openGemini: openGemini is an open-source,cloud-native time-series database(TSDB) that can be widely used in IoT, Internet of Vehicles(IoV), O&M monitoring, and industrial Internet scenarios.
  • AdGuardDNS: AdGuard DNS is an alternative solution for tracker blocking, privacy protection, and parental control.
  • WatchAD2.0: WatchAD2.0 ๆ˜ฏ 360 ไฟกๆฏๅฎ‰ๅ…จไธญๅฟƒๅผ€ๅ‘็š„ไธ€ๆฌพ้’ˆๅฏนๅŸŸๅฎ‰ๅ…จ็š„ๆ—ฅๅฟ—ๅˆ†ๆžไธŽ็›‘ๆŽง็ณป็ปŸ๏ผŒๅฎƒๅฏไปฅๆ”ถ้›†ๆ‰€ๆœ‰ๅŸŸๆŽงไธŠ็š„ไบ‹ไปถๆ—ฅๅฟ—ใ€็ฝ‘็ปœๆต้‡๏ผŒ้€š่ฟ‡็‰นๅพๅŒน้…ใ€ๅ่ฎฎๅˆ†ๆžใ€ๅކๅฒ่กŒไธบใ€ๆ•ๆ„Ÿๆ“ไฝœๅ’Œ่œœ็ฝ่ดฆๆˆท็ญ‰ๆ–นๅผๆฅๆฃ€ๆต‹ๅ„็งๅทฒ็ŸฅไธŽๆœช็Ÿฅๅจ่ƒ๏ผŒๅŠŸ่ƒฝ่ฆ†็›–ไบ†ๅคง้ƒจๅˆ†็›ฎๅ‰็š„ๅธธ่งๅ†…็ฝ‘ๅŸŸๆธ—้€ๆ‰‹ๆณ•ใ€‚
  • vanus: Vanus is a Serverless, event streaming system with processing capabilities. It easily connects SaaS, Cloud Services, and Databases to help users build next-gen Event-driven Applications.
  • trpc-go: A pluggable, high-performance RPC framework written in Golang.
  • motan-go: Motan is a cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services. motan-go is the golang implementation of Motan.

All use cases:

If you have ants integrated into projects, feel free to open a pull request refreshing this list of use cases.

๐Ÿ”‹ JetBrains OS licenses

ants has been being developed with GoLand under the free JetBrains Open Source license(s) granted by JetBrains s.r.o., hence I would like to express my thanks here.

โ˜•๏ธ Buy me a coffee

Please be sure to leave your name, GitHub account, or other social media accounts when you donate by the following means so that I can add it to the list of donors as a token of my appreciation.

๐Ÿ”‹ Sponsorship


File: CODE_OF_CONDUCT.md

Contributor Covenant Code of Conduct

Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

Our Standards

Examples of behavior that contributes to creating a positive environment
include:

  • Using welcoming and inclusive language
  • Being respectful of differing viewpoints and experiences
  • Gracefully accepting constructive criticism
  • Focusing on what is best for the community
  • Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

  • The use of sexualized language or imagery and unwelcome sexual attention or
    advances
  • Trolling, insulting/derogatory comments, and personal or political attacks
  • Public or private harassment
  • Publishing others' private information, such as a physical or electronic
    address, without explicit permission
  • Other conduct which could reasonably be considered inappropriate in a
    professional setting

Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

Attribution

This Code of Conduct is adapted from the Contributor Covenant, version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq


File: CONTRIBUTING.md

Contributing

With issues:

  • Use the search tool before opening a new issue.
  • Please provide source code and commit sha if you found a bug.
  • Review existing issues and provide feedback or react to them.

With pull requests:

  • Open your pull request against dev.
  • Open one pull request for only one feature/proposal, if you have several those, please put them into different PRs, whereas you are allowed to open one pull request with several bug-fixs.
  • Your pull request should have no more than two commits, if not, you should squash them.
  • It should pass all tests in the available continuous integrations systems such as TravisCI.
  • You should add/modify tests to cover your proposed code changes.
  • If your pull request contains a new feature, please document it on the README.

File: README_ZH.md

่‹ฑๆ–‡ | ไธญๆ–‡

๐Ÿ“– ็ฎ€ไป‹

ants ๆ˜ฏไธ€ไธช้ซ˜ๆ€ง่ƒฝ็š„ goroutine ๆฑ ๏ผŒๅฎž็Žฐไบ†ๅฏนๅคง่ง„ๆจก goroutine ็š„่ฐƒๅบฆ็ฎก็†ใ€goroutine ๅค็”จ๏ผŒๅ…่ฎธไฝฟ็”จ่€…ๅœจๅผ€ๅ‘ๅนถๅ‘็จ‹ๅบ็š„ๆ—ถๅ€™้™ๅˆถ goroutine ๆ•ฐ้‡๏ผŒๅค็”จ่ต„ๆบ๏ผŒ่พพๅˆฐๆ›ด้ซ˜ๆ•ˆๆ‰ง่กŒไปปๅŠก็š„ๆ•ˆๆžœใ€‚

๐Ÿš€ ๅŠŸ่ƒฝ๏ผš

  • ่‡ชๅŠจ่ฐƒๅบฆๆตท้‡็š„ goroutines๏ผŒๅค็”จ goroutines
  • ๅฎšๆœŸๆธ…็†่ฟ‡ๆœŸ็š„ goroutines๏ผŒ่ฟ›ไธ€ๆญฅ่Š‚็œ่ต„ๆบ
  • ๆไพ›ไบ†ๅคง้‡ๅฎž็”จ็š„ๆŽฅๅฃ๏ผšไปปๅŠกๆไบคใ€่Žทๅ–่ฟ่กŒไธญ็š„ goroutine ๆ•ฐ้‡ใ€ๅŠจๆ€่ฐƒๆ•ด Pool ๅคงๅฐใ€้‡Šๆ”พ Poolใ€้‡ๅฏ Pool ็ญ‰
  • ไผ˜้›…ๅค„็† panic๏ผŒ้˜ฒๆญข็จ‹ๅบๅดฉๆบƒ
  • ่ต„ๆบๅค็”จ๏ผŒๆžๅคง่Š‚็œๅ†…ๅญ˜ไฝฟ็”จ้‡๏ผ›ๅœจๅคง่ง„ๆจกๆ‰น้‡ๅนถๅ‘ไปปๅŠกๅœบๆ™ฏไธ‹็”š่‡ณๅฏ่ƒฝๆฏ” Go ่ฏญ่จ€็š„ๆ— ้™ๅˆถ goroutine ๅนถๅ‘ๅ…ทๆœ‰ๆ›ด้ซ˜็š„ๆ€ง่ƒฝ
  • ้ž้˜ปๅกžๆœบๅˆถ
  • ้ข„ๅˆ†้…ๅ†…ๅญ˜ (็Žฏๅฝข้˜Ÿๅˆ—๏ผŒๅฏ้€‰)

๐Ÿ’ก `ants` ๆ˜ฏๅฆ‚ไฝ•่ฟ่กŒ็š„

ๆต็จ‹ๅ›พ

ๅŠจๆ€ๅ›พ

๐Ÿงฐ ๅฎ‰่ฃ…

ไฝฟ็”จ `ants` v1 ็‰ˆๆœฌ:

powershell
go get -u github.com/panjf2000/ants

ไฝฟ็”จ `ants` v2 ็‰ˆๆœฌ (ๅผ€ๅฏ GO111MODULE=on):

powershell
go get -u github.com/panjf2000/ants/v2

๐Ÿ›  ไฝฟ็”จ

ๅŸบๆœฌ็š„ไฝฟ็”จ่ฏทๆŸฅ็œ‹็คบไพ‹.

Pool ้…็ฝฎ

้€š่ฟ‡ๅœจ่ฐƒ็”จ NewPool/NewPoolWithFunc/NewPoolWithFuncGeneric ไน‹ๆ—ถไฝฟ็”จๅ„็ง optional function๏ผŒๅฏไปฅ่ฎพ็ฝฎ ants.Options ไธญๅ„ไธช้…็ฝฎ้กน็š„ๅ€ผ๏ผŒ็„ถๅŽ็”จๅฎƒๆฅๅฎšๅˆถๅŒ– goroutine poolใ€‚

ๆ›ดๅคš็ป†่Š‚่ฏทๆŸฅ็œ‹ ants.Options ๅ’Œ ants.Option

่‡ชๅฎšไน‰ pool ๅฎน้‡

ants ๆ”ฏๆŒๅฎžไพ‹ๅŒ–ไฝฟ็”จ่€…่‡ชๅทฑ็š„ไธ€ไธช Pool๏ผŒๆŒ‡ๅฎšๅ…ทไฝ“็š„ pool ๅฎน้‡๏ผ›้€š่ฟ‡่ฐƒ็”จ NewPool ๆ–นๆณ•ๅฏไปฅๅฎžไพ‹ๅŒ–ไธ€ไธชๆ–ฐ็š„ๅธฆๆœ‰ๆŒ‡ๅฎšๅฎน้‡็š„ Pool๏ผŒๅฆ‚ไธ‹๏ผš

go
p, _ := ants.NewPool(10000)

ไปปๅŠกๆไบค

ๆไบคไปปๅŠก้€š่ฟ‡่ฐƒ็”จ ants.Submit ๆ–นๆณ•๏ผš

go
ants.Submit(func(){})

ๅŠจๆ€่ฐƒๆ•ด goroutine ๆฑ ๅฎน้‡

้œ€่ฆๅŠจๆ€่ฐƒๆ•ด pool ๅฎน้‡ๅฏไปฅ้€š่ฟ‡่ฐƒ็”จ ants.Tune๏ผš

go
pool.Tune(1000) // Tune its capacity to 1000
pool.Tune(100000) // Tune its capacity to 100000

่ฏฅๆ–นๆณ•ๆ˜ฏ็บฟ็จ‹ๅฎ‰ๅ…จ็š„ใ€‚

้ข„ๅ…ˆๅˆ†้… goroutine ้˜Ÿๅˆ—ๅ†…ๅญ˜

ants ๆ”ฏๆŒ้ข„ๅ…ˆไธบ pool ๅˆ†้…ๅฎน้‡็š„ๅ†…ๅญ˜๏ผŒ ่ฟ™ไธชๅŠŸ่ƒฝๅฏไปฅๅœจๆŸไบ›็‰นๅฎš็š„ๅœบๆ™ฏไธ‹ๆ้ซ˜ goroutine ๆฑ ็š„ๆ€ง่ƒฝใ€‚ๆฏ”ๅฆ‚๏ผŒ ๆœ‰ไธ€ไธชๅœบๆ™ฏ้œ€่ฆไธ€ไธช่ถ…ๅคงๅฎน้‡็š„ๆฑ ๏ผŒ่€Œไธ”ๆฏไธช goroutine ้‡Œ้ข็š„ไปปๅŠก้ƒฝๆ˜ฏ่€—ๆ—ถไปปๅŠก๏ผŒ่ฟ™็งๆƒ…ๅ†ตไธ‹๏ผŒ้ข„ๅ…ˆๅˆ†้… goroutine ้˜Ÿๅˆ—ๅ†…ๅญ˜ๅฐ†ไผšๅ‡ๅฐ‘ไธๅฟ…่ฆ็š„ๅ†…ๅญ˜้‡ๆ–ฐๅˆ†้…ใ€‚

go
// ๆๅ‰ๅˆ†้…็š„ pool ๅฎน้‡็š„ๅ†…ๅญ˜็ฉบ้—ด
p, _ := ants.NewPool(100000, ants.WithPreAlloc(true))

้‡Šๆ”พ Pool

go
pool.Release()

ๆˆ–่€…

go
pool.ReleaseTimeout(time.Second * 3)

้‡ๅฏ Pool

go
// ๅช่ฆ่ฐƒ็”จ Reboot() ๆ–นๆณ•๏ผŒๅฐฑๅฏไปฅ้‡ๆ–ฐๆฟ€ๆดปไธ€ไธชไน‹ๅ‰ๅทฒ็ป่ขซ้”€ๆฏๆމ็š„ๆฑ ๏ผŒๅนถไธ”ๆŠ•ๅ…ฅไฝฟ็”จใ€‚
pool.Reboot()

โš™๏ธ ๅ…ณไบŽไปปๅŠกๆ‰ง่กŒ้กบๅบ

ants ๅนถไธไฟ่ฏๆไบค็š„ไปปๅŠก่ขซๆ‰ง่กŒ็š„้กบๅบ๏ผŒๆ‰ง่กŒ็š„้กบๅบไนŸไธๆ˜ฏๅ’Œๆไบค็š„้กบๅบไฟๆŒไธ€่‡ด๏ผŒๅ› ไธบๅœจ ants ๆ˜ฏๅนถๅ‘ๅœฐๅค„็†ๆ‰€ๆœ‰ๆไบค็š„ไปปๅŠก๏ผŒๆไบค็š„ไปปๅŠกไผš่ขซๅˆ†ๆดพๅˆฐๆญฃๅœจๅนถๅ‘่ฟ่กŒ็š„ workers ไธŠๅŽป๏ผŒๅ› ๆญค้‚ฃไบ›ไปปๅŠกๅฐ†ไผš่ขซๅนถๅ‘ไธ”ๆ— ๅบๅœฐ่ขซๆ‰ง่กŒใ€‚

๐Ÿ‘ ่ดก็Œฎ่€…

่ฏทๅœจๆ PR ไน‹ๅ‰ไป”็ป†้˜…่ฏป Contributing Guidelines๏ผŒๆ„Ÿ่ฐข้‚ฃไบ›ไธบ ants ่ดก็Œฎ่ฟ‡ไปฃ็ ็š„ๅผ€ๅ‘่€…๏ผ

๐Ÿ“„ ่ฏไนฆ

ants ็š„ๆบ็ ๅ…่ฎธ็”จๆˆทๅœจ้ตๅพช MIT ๅผ€ๆบ่ฏไนฆ ่ง„ๅˆ™็š„ๅ‰ๆไธ‹ไฝฟ็”จใ€‚

๐Ÿ“š ็›ธๅ…ณๆ–‡็ซ 

๐Ÿ–ฅ ็”จๆˆทๆกˆไพ‹

ๅ•†ไธšๅ…ฌๅธๅ’Œๅผ€ๆบ็ป„็ป‡

ไปฅไธ‹ๅ…ฌๅธ/็ป„็ป‡ๅœจ็”Ÿไบง็ŽฏๅขƒไธŠไฝฟ็”จไบ† antsใ€‚

ๅฆ‚ๆžœไฝ ไนŸๆญฃๅœจ็”Ÿไบง็ŽฏๅขƒไธŠไฝฟ็”จ ants๏ผŒๆฌข่ฟŽๆ PR ๆฅไธฐๅฏŒ่ฟ™ไปฝๅˆ—่กจใ€‚

ๅผ€ๆบ่ฝฏไปถ

่ฟ™ไบ›ๅผ€ๆบ้กน็›ฎๅ€ŸๅŠฉ ants ่ฟ›่กŒๅนถๅ‘็ผ–็จ‹ใ€‚

  • gnet: gnet ๆ˜ฏไธ€ไธช้ซ˜ๆ€ง่ƒฝใ€่ฝป้‡็บงใ€้ž้˜ปๅกž็š„ไบ‹ไปถ้ฉฑๅŠจ Go ็ฝ‘็ปœๆก†ๆžถใ€‚
  • milvus: ไธ€ไธช้ซ˜ๅบฆ็ตๆดปใ€ๅฏ้ ไธ”้€Ÿๅบฆๆžๅฟซ็š„ไบ‘ๅŽŸ็”Ÿๅผ€ๆบๅ‘้‡ๆ•ฐๆฎๅบ“ใ€‚
  • nps: ไธ€ๆฌพ่ฝป้‡็บงใ€้ซ˜ๆ€ง่ƒฝใ€ๅŠŸ่ƒฝๅผบๅคง็š„ๅ†…็ฝ‘็ฉฟ้€ไปฃ็†ๆœๅŠกๅ™จใ€‚
  • TDengine: TDengine ๆ˜ฏไธ€ๆฌพๅผ€ๆบใ€้ซ˜ๆ€ง่ƒฝใ€ไบ‘ๅŽŸ็”Ÿ็š„ๆ—ถๅบๆ•ฐๆฎๅบ“ (Time-Series Database, TSDB)ใ€‚TDengine ่ƒฝ่ขซๅนฟๆณ›่ฟ็”จไบŽ็‰ฉ่”็ฝ‘ใ€ๅทฅไธšไบ’่”็ฝ‘ใ€่ฝฆ่”็ฝ‘ใ€IT ่ฟ็ปดใ€้‡‘่ž็ญ‰้ข†ๅŸŸใ€‚
  • siyuan: ๆ€ๆบ็ฌ”่ฎฐๆ˜ฏไธ€ๆฌพๆœฌๅœฐไผ˜ๅ…ˆ็š„ไธชไบบ็Ÿฅ่ฏ†็ฎก็†็ณป็ปŸ๏ผŒๆ”ฏๆŒๅฎŒๅ…จ็ฆป็บฟไฝฟ็”จ๏ผŒๅŒๆ—ถไนŸๆ”ฏๆŒ็ซฏๅˆฐ็ซฏๅŠ ๅฏ†ๅŒๆญฅใ€‚
  • BillionMail: BillionMail ๆ˜ฏไธ€ไธชๆœชๆฅ็š„ๅผ€ๆบ้‚ฎไปถๆœๅŠกๅ™จๅ’Œ็”ตๅญ้‚ฎไปถ่ฅ้”€ๅนณๅฐ๏ผŒๆ—จๅœจๅธฎๅŠฉไผไธšๅ’Œไธชไบบ่ฝปๆพ็ฎก็†ไป–ไปฌ็š„็”ตๅญ้‚ฎไปถ่ฅ้”€ๆดปๅŠจใ€‚
  • WeKnora: ไธ€ๆฌพๅŸบไบŽๅคง่ฏญ่จ€ๆจกๅž‹๏ผˆLLM๏ผ‰็š„ๆ–‡ๆกฃ็†่งฃไธŽ่ฏญไน‰ๆฃ€็ดขๆก†ๆžถ๏ผŒไธ“ไธบ็ป“ๆž„ๅคๆ‚ใ€ๅ†…ๅฎนๅผ‚ๆž„็š„ๆ–‡ๆกฃๅœบๆ™ฏ่€Œๆ‰“้€ ใ€‚
  • coze-loop: Coze Loop ๆ˜ฏไธ€ไธช้ขๅ‘ๅผ€ๅ‘่€…๏ผŒไธ“ๆณจไบŽ AI Agent ๅผ€ๅ‘ไธŽ่ฟ็ปด็š„ๅนณๅฐ็บง่งฃๅ†ณๆ–นๆกˆใ€‚
  • osmedeus: A Workflow Engine for Offensive Security.
  • jitsu: An open-source Segment alternative. Fully-scriptable data ingestion engine for modern data teams. Set-up a real-time data pipeline in minutes, not days.
  • triangula: Generate high-quality triangulated and polygonal art from images.
  • teler: Real-time HTTP Intrusion Detection.
  • bsc: A Binance Smart Chain client based on the go-ethereum fork.
  • jaeles: The Swiss Army knife for automated Web Application Testing.
  • devlake: The open-source dev data platform & dashboard for your DevOps tools.
  • matrixone: MatrixOne ๆ˜ฏไธ€ๆฌพ้ขๅ‘ๆœชๆฅ็š„่ถ…่žๅˆๅผ‚ๆž„ไบ‘ๅŽŸ็”Ÿๆ•ฐๆฎๅบ“๏ผŒ้€š่ฟ‡่ถ…่žๅˆๆ•ฐๆฎๅผ•ๆ“Žๆ”ฏๆŒไบ‹ๅŠก/ๅˆ†ๆž/ๆตๅค„็†็ญ‰ๆททๅˆๅทฅไฝœ่ดŸ่ฝฝ๏ผŒ้€š่ฟ‡ๅผ‚ๆž„ไบ‘ๅŽŸ็”Ÿๆžถๆž„ๆ”ฏๆŒ่ทจๆœบๆˆฟๅๅŒ/ๅคšๅœฐๅๅŒ/ไบ‘่พนๅๅŒใ€‚็ฎ€ๅŒ–ๅผ€ๅ‘่ฟ็ปด๏ผŒๆถˆ็ฎ€ๆ•ฐๆฎ็ขŽ็‰‡๏ผŒๆ‰“็ ดๆ•ฐๆฎ็š„็ณป็ปŸใ€ไฝ็ฝฎๅ’Œๅˆ›ๆ–ฐ่พน็•Œใ€‚
  • bk-bcs: ่“้ฒธๅฎนๅ™จ็ฎก็†ๅนณๅฐ๏ผˆBlueking Container Service๏ผ‰ๅฎšไฝไบŽๆ‰“้€ ไบ‘ๅŽŸ็”ŸๆŠ€ๆœฏๅ’ŒไธšๅŠกๅฎž้™…ๅบ”็”จๅœบๆ™ฏไน‹้—ด็š„ๆกฅๆข๏ผ›่š็„ฆไบŽๅคๆ‚ๅบ”็”จๅœบๆ™ฏ็š„ๅฎนๅ™จๅŒ–้ƒจ็ฝฒๆŠ€ๆœฏๆ–นๆกˆ็š„็ ”ๅ‘ใ€ๆ•ดๅˆๅ’Œไบงๅ“ๅŒ–๏ผ›่‡ดๅŠ›ไบŽไธบๆธธๆˆ็ญ‰ๅคๆ‚ๅบ”็”จๆไพ›ไธ€็ซ™ๅผใ€ไฝŽ้—จๆง›็š„ๅฎนๅ™จ็ผ–ๆŽ’ๅ’ŒๆœๅŠกๆฒป็†ๆœๅŠกใ€‚
  • trueblocks-core: TrueBlocks improves access to blockchain data for any EVM-compatible chain (particularly Ethereum mainnet) while remaining entirely local.
  • openGemini: openGemini ๆ˜ฏๅŽไธบไบ‘ๅผ€ๆบ็š„ไธ€ๆฌพไบ‘ๅŽŸ็”Ÿๅˆ†ๅธƒๅผๆ—ถๅบๆ•ฐๆฎๅบ“๏ผŒๅฏๅนฟๆณ›ๅบ”็”จไบŽ็‰ฉ่”็ฝ‘ใ€่ฝฆ่”็ฝ‘ใ€่ฟ็ปด็›‘ๆŽงใ€ๅทฅไธšไบ’่”็ฝ‘็ญ‰ไธšๅŠกๅœบๆ™ฏ๏ผŒๅ…ทๅค‡ๅ“่ถŠ็š„่ฏปๅ†™ๆ€ง่ƒฝๅ’Œ้ซ˜ๆ•ˆ็š„ๆ•ฐๆฎๅˆ†ๆž่ƒฝๅŠ›๏ผŒ้‡‡็”จ็ฑปSQLๆŸฅ่ฏข่ฏญ่จ€๏ผŒๆ— ็ฌฌไธ‰ๆ–น่ฝฏไปถไพ่ต–ใ€ๅฎ‰่ฃ…็ฎ€ๅ•ใ€้ƒจ็ฝฒ็ตๆดปใ€่ฟ็ปดไพฟๆทใ€‚
  • AdGuardDNS: AdGuard DNS is an alternative solution for tracker blocking, privacy protection, and parental control.
  • WatchAD2.0: WatchAD2.0 ๆ˜ฏ 360 ไฟกๆฏๅฎ‰ๅ…จไธญๅฟƒๅผ€ๅ‘็š„ไธ€ๆฌพ้’ˆๅฏนๅŸŸๅฎ‰ๅ…จ็š„ๆ—ฅๅฟ—ๅˆ†ๆžไธŽ็›‘ๆŽง็ณป็ปŸ๏ผŒๅฎƒๅฏไปฅๆ”ถ้›†ๆ‰€ๆœ‰ๅŸŸๆŽงไธŠ็š„ไบ‹ไปถๆ—ฅๅฟ—ใ€็ฝ‘็ปœๆต้‡๏ผŒ้€š่ฟ‡็‰นๅพๅŒน้…ใ€ๅ่ฎฎๅˆ†ๆžใ€ๅކๅฒ่กŒไธบใ€ๆ•ๆ„Ÿๆ“ไฝœๅ’Œ่œœ็ฝ่ดฆๆˆท็ญ‰ๆ–นๅผๆฅๆฃ€ๆต‹ๅ„็งๅทฒ็ŸฅไธŽๆœช็Ÿฅๅจ่ƒ๏ผŒๅŠŸ่ƒฝ่ฆ†็›–ไบ†ๅคง้ƒจๅˆ†็›ฎๅ‰็š„ๅธธ่งๅ†…็ฝ‘ๅŸŸๆธ—้€ๆ‰‹ๆณ•ใ€‚
  • vanus: Vanus is a Serverless, event streaming system with processing capabilities. It easily connects SaaS, Cloud Services, and Databases to help users build next-gen Event-driven Applications.
  • trpc-go: ไธ€ไธช Go ๅฎž็Žฐ็š„ๅฏๆ’ๆ‹”็š„้ซ˜ๆ€ง่ƒฝ RPC ๆก†ๆžถใ€‚
  • motan-go: Motan ๆ˜ฏไธ€ๅฅ—้ซ˜ๆ€ง่ƒฝใ€ๆ˜“ไบŽไฝฟ็”จ็š„ๅˆ†ๅธƒๅผ่ฟœ็จ‹ๆœๅŠก่ฐƒ็”จ (RPC) ๆก†ๆžถใ€‚motan-go ๆ˜ฏ motan ็š„ Go ่ฏญ่จ€ๅฎž็Žฐใ€‚

ๆ‰€ๆœ‰ๆกˆไพ‹:

ๅฆ‚ๆžœไฝ ็š„้กน็›ฎไนŸๅœจไฝฟ็”จ ants๏ผŒๆฌข่ฟŽ็ป™ๆˆ‘ๆ Pull Request ๆฅๆ›ดๆ–ฐ่ฟ™ไปฝ็”จๆˆทๆกˆไพ‹ๅˆ—่กจใ€‚

๐Ÿ”‹ JetBrains ๅผ€ๆบ่ฏไนฆๆ”ฏๆŒ

ants ้กน็›ฎไธ€็›ดไปฅๆฅ้ƒฝๆ˜ฏๅœจ JetBrains ๅ…ฌๅธๆ——ไธ‹็š„ GoLand ้›†ๆˆๅผ€ๅ‘็Žฏๅขƒไธญ่ฟ›่กŒๅผ€ๅ‘๏ผŒๅŸบไบŽ free JetBrains Open Source license(s) ๆญฃ็‰ˆๅ…่ดนๆŽˆๆƒ๏ผŒๅœจๆญค่กจ่พพๆˆ‘็š„่ฐขๆ„ใ€‚

โ˜•๏ธ ๆ‰“่ต

ๅฝ“ๆ‚จ้€š่ฟ‡ไปฅไธ‹ๆ–นๅผ่ฟ›่กŒๆ่ต ๆ—ถ๏ผŒ่ฏทๅŠกๅฟ…็•™ไธ‹ๅง“ๅใ€GitHub ่ดฆๅทๆˆ–ๅ…ถไป–็คพไบคๅช’ไฝ“่ดฆๅท๏ผŒไปฅไพฟๆˆ‘ๅฐ†ๅ…ถๆทปๅŠ ๅˆฐๆ่ต ่€…ๅๅ•ไธญ๏ผŒไปฅ่กจ่ฐขๆ„ใ€‚

๐Ÿ”‹ ่ตžๅŠฉๅ•†


File: .github/FUNDING.yml

These are supported funding model platforms

github: [panjf2000]
patreon: panjf2000
open_collective: panjf2000
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']


File: .github/pull_request_template.md

1. Are you opening this pull request for bug-fixs, optimizations or new feature?

2. Please describe how these code changes achieve your intention.

4. Which documentation changes (if any) need to be made/updated because of this PR?

4. Checklist

  • I have squashed all insignificant commits.
  • I have commented my code for explaining package types, values, functions, and non-obvious lines.
  • I have written unit tests and verified that all tests passes (if needed).
  • I have documented feature info on the README (only when this PR is adding a new feature).
  • (optional) I am willing to help maintain this change if there are issues with it later.

File: .github/release-drafter.yml

name-template: Ants v$RESOLVED_VERSION
tag-template: v$RESOLVED_VERSION
categories:
- title: ๐Ÿงจ Breaking changes
labels:
- breaking changes
- title: ๐Ÿš€ Features
labels:
- proposal
- new feature
- title: ๐Ÿ›ฉ Enhancements
labels:
- enhancement
- optimization
- title: ๐Ÿ› Bugfixes
labels:
- bug
- title: ๐Ÿ“š Documentation
labels:
- doc
- docs
- title: ๐Ÿ—ƒ Misc
labels:
- chores
change-template: '- $TITLE (#$NUMBER)'
change-title-escapes: '<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- major
minor:
labels:
- minor
- new feature
- proposal
patch:
labels:
- patch
- bug
- dependencies
default: patch
autolabeler:

  • label: bug
    title:

    • /fix/i
    • /bug/i
    • /resolve/i
  • label: docs
    files:

    • '*.md'
      title:
    • /doc/i
    • /README/i
  • label: enhancement
    title:

    • /opt:/i
    • /refactor/i
    • /optimize/i
    • /improve/i
    • /update/i
    • /remove/i
    • /delete/i
  • label: optimization
    title:

    • /opt:/i
    • /refactor/i
    • /optimize/i
    • /improve/i
    • /update/i
    • /remove/i
    • /delete/i
  • label: new feature
    title:

    • /feat:/i
    • /feature/i
    • /implement/i
    • /add/i
    • /minor/i
  • label: dependencies
    title:

    • /dependencies/i
    • /upgrade/i
    • /bump up/i
  • label: chores
    title:

    • /chore/i
    • /misc/i
    • /cleanup/i
    • /clean up/i
  • label: major
    title:

    • /major:/i
  • label: minor
    title:

    • /minor:/i
  • label: patch
    title:

    • /patch:/i
      template: |

    Changelogs

    $CHANGES

    Full Changelog: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION

    Thanks to all these contributors: $CONTRIBUTORS for making this release possible.


File: .github/ISSUE_TEMPLATE/bug-report.yaml

name: Bug Report
title: "[Bug]: "
labels: ["bug"]
assignees:

  • panjf2000
    body:
  • type: markdown
    id: tips
    attributes:
    value: |
    ## Before you go any further
    - Please read How To Ask Questions The Smart Way ( Chinese translation: ใ€Šๆ้—ฎ็š„ๆ™บๆ…งใ€‹) before you file an issue formally.
    - Keep in mind that there is always welcome to ask questions on Discord.
  • type: checkboxes
    id: checklist
    attributes:
    label: Actions I've taken before I'm here
    options:
    - label: I've thoroughly read the documentations on this issue but still have no clue.
    required: true
    - label: I've searched the current list of Github issues but didn't find any duplicate issues that have been solved.
    required: true
    - label: I've searched the internet with this issue, but haven't found anything helpful.
    required: true

    validations:
    required: true
  • type: textarea
    id: bug-report
    attributes:
    label: What happened?
    placeholder: Please describe what happened and how it happened, the more details you provide, the faster the bug gets fixed.
    validations:
    required: true
  • type: dropdown
    id: major-version
    attributes:
    label: Major version of ants
    options:
    - v2
    - v1

    validations:
    required: true
  • type: input
    id: specific-version
    attributes:
    label: Specific version of ants
    placeholder: "For example: v2.6.0"
    validations:
    required: true
  • type: dropdown
    id: os
    attributes:
    label: Operating system
    multiple: true
    options:
    - Linux
    - macOS
    - Windows
    - BSD

    validations:
    required: true
  • type: input
    id: os-version
    attributes:
    label: OS version
    placeholder: "Run uname -srm command to get the info, for example: Darwin 21.5.0 arm64, Linux 5.4.0-137-generic x86_64"
    validations:
    required: true
  • type: input
    id: go-version
    attributes:
    label: Go version
    placeholder: "Run go version command to get the info, for example: go1.20.5 linux/amd64"
    validations:
    required: true
  • type: textarea
    id: logs
    attributes:
    label: Relevant log output
    render: shell
    validations:
    required: true
  • type: textarea
    id: code
    attributes:
    label: Reproducer
    render: go
  • type: textarea
    id: how-to-reproduce
    attributes:
    label: How to Reproduce
    placeholder: Tell us step by step how we can replicate this bug and what we should see in the end.
    value: |
    Steps to reproduce the behavior:
    1. Go to '....'
    2. Click on '....'
    3. Do '....'
    4. See '....'

    validations:
    required: true
  • type: dropdown
    id: bug-in-latest-code
    attributes:
    label: Does this issue reproduce with the latest release?
    options:
    - It can reproduce with the latest release
    - It gets fixed in the latest release
    - I haven't verified it with the latest release

    validations:
    required: true

File: .github/ISSUE_TEMPLATE/feature-request.yaml

name: Feature Request
title: "[Feature]: "
labels: ["proposal", "enhancement"]
assignees:

  • panjf2000
    body:
  • type: markdown
    id: tips
    attributes:
    value: |
    ## Before you go any further
    - Please read How To Ask Questions The Smart Way ( Chinese translation: ใ€Šๆ้—ฎ็š„ๆ™บๆ…งใ€‹) before you file an issue formally.
    - Keep in mind that there is always welcome to ask questions on Discord.
  • type: textarea
    id: feature-request
    attributes:
    label: Description of new feature
    placeholder: Describe this new feature with critical details.
    validations:
    required: true
  • type: textarea
    id: feature-scenario
    attributes:
    label: Scenarios for new feature
    placeholder: Please try to convince us that this new feature makes sense, also it will improve ants.
    validations:
    required: true
  • type: dropdown
    id: breaking-changes
    attributes:
    label: Breaking changes or not?
    options:
    - "Yes"
    - "No"

    validations:
    required: true
  • type: textarea
    id: code
    attributes:
    label: Code snippets (optional)
    render: go
  • type: textarea
    id: feature-alternative
    attributes:
    label: Alternatives for new feature
    placeholder: A concise but clear description of any alternative solutions or features you had in mind.
    value: None.
  • type: textarea
    id: additional-context
    attributes:
    label: Additional context (optional)
    placeholder: What else should we know before we start discussing this new feature?
    value: None.

File: .github/ISSUE_TEMPLATE/question.yaml

name: Question
title: "[Question]: "
labels: ["question", "help wanted"]
body:

  • type: markdown
    id: tips
    attributes:
    value: |
    ## Before you go any further
    - Please read How To Ask Questions The Smart Way ( Chinese translation: ใ€Šๆ้—ฎ็š„ๆ™บๆ…งใ€‹) before you file an issue formally.
    - Keep in mind that there is always welcome to ask questions on Discord.
  • type: textarea
    id: question
    attributes:
    label: Questions with details
    placeholder: Describe your question with critical details here.
    validations:
    required: true
  • type: textarea
    id: code
    attributes:
    label: Code snippets (optional)
    render: go

File: .github/workflows/codeql.yml

name: "Code scanning"

on:
push:
branches:
- master
- dev
paths-ignore:
- '.md'
- '
.yml'
- '.yaml'
- '!.github/workflows/codeql.yml'
pull_request:
branches:
- master
- dev
paths-ignore:
- '
.md'
- '.yml'
- '
.yaml'
- '!.github/workflows/codeql.yml'
schedule:
# โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ minute (0 - 59)
# โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ hour (0 - 23)
# โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ day of the month (1 - 31)
# โ”‚ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ month (1 - 12 or JAN-DEC)
# โ”‚ โ”‚ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ day of the week (0 - 6 or SUN-SAT)
# โ”‚ โ”‚ โ”‚ โ”‚ โ”‚
# โ”‚ โ”‚ โ”‚ โ”‚ โ”‚
# โ”‚ โ”‚ โ”‚ โ”‚ โ”‚
# * * * * *
- cron: '30 4 * * 6'

jobs:
CodeQL-Build:
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
runs-on: ubuntu-latest

text
permissions:
  # required for all workflows
  security-events: write

steps:
  - name: Checkout repository
    uses: actions/checkout@v4
    with:
      fetch-depth: 2

  # Initializes the CodeQL tools for scanning.
  - name: Initialize CodeQL
    uses: github/codeql-action/init@v3
    with:
      languages: go

  # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
  # If this step fails, then you should remove it and run the build manually (see below).
  - name: Autobuild
    uses: github/codeql-action/autobuild@v3

  # โ„น๏ธ Command-line programs to run using the OS shell.
  # ๐Ÿ“š See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

  # โœ๏ธ If the Autobuild fails above, remove it and uncomment the following
  #    three lines and modify them (or add more) to build your code if your
  #    project uses a compiled language

  #- run: |
  #     make bootstrap
  #     make release

  - name: Perform CodeQL Analysis
    uses: github/codeql-action/analyze@v3

File: .github/workflows/pull-request.yml

name: Check pull request target
on:
pull_request:
types:
- opened
- reopened
- synchronize
branches:
- master
jobs:
check-branches:
runs-on: ubuntu-latest
steps:
- name: Check target branch
run: |
if [ ${{ github.head_ref }} != "dev" ]; then
echo "Only pull requests from dev branch are only allowed to be merged into master branch."
exit 1
fi


File: .github/workflows/release-drafter.yml

name: Release Drafter

on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- master

pull_request event is required only for autolabeler

pull_request:
# Only following types are handled by the action, but one can default to all as well
types: [opened, reopened, synchronize]

pull_request_target event is required for autolabeler to support PRs from forks

pull_request_target:

types: [opened, reopened, synchronize]

permissions:
contents: read

jobs:
update_release_draft:
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
# (Optional) GitHub Enterprise requires GHE_HOST variable set
#- name: Set GHE_HOST
# run: |
# echo "GHE_HOST=${GITHUB_SERVER_URL##https://}" >> $GITHUB_ENV

text
# Drafts your next Release notes as Pull Requests are merged into "master"
  - uses: release-drafter/release-drafter@v6
    # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
    # with:
    #   config-name: my-config.yml
    #   disable-autolabeler: true
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

File: .github/workflows/stale-bot.yml

name: Monitor inactive issues and PRs
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:

jobs:
stale-issues:
runs-on: ubuntu-latest
permissions:
actions: write
issues: write
pull-requests: write
steps:
- uses: actions/stale@v9
with:
operations-per-run: 50
days-before-issue-stale: 30
days-before-issue-close: 7
stale-issue-label: 'stale'
stale-issue-message: |
This issue is marked as stale because it has been open for 30 days with no activity.

text
You should take one of the following actions:
        - Manually close this issue if it is no longer relevant
        - Comment if you have more information to share
        
        This issue will be automatically closed in 7 days if no further activity occurs.
      close-issue-message: |
        This issue was closed because it has been inactive for 7 days since being marked as stale.

        If you believe this is a false alarm, please leave a comment for it or open a new issue, you can also reopen this issue directly if you have permission.
      days-before-pr-stale: 21
      days-before-pr-close: 7
      stale-pr-label: 'stale'
      stale-pr-message: |
        This PR is marked as stale because it has been open for 21 days with no activity.
        
        You should take one of the following actions:
        - Manually close this PR if it is no longer relevant
        - Push new commits or comment if you have more information to share
        
        This PR will be automatically closed in 7 days if no further activity occurs.
      close-pr-message: |
        This PR was closed because it has been inactive for 7 days since being marked as stale.

        If you believe this is a false alarm, feel free to reopen this PR or create a new one.
      repo-token: ${{ secrets.GITHUB_TOKEN }}

File: .github/workflows/test.yml

name: Run tests

on:
push:
branches:
- master
- dev
paths-ignore:
- '.md'
- '
.yml'
- '.yaml'
- 'examples/*'
- '!.github/workflows/test.yml'
pull_request:
branches:
- master
- dev
paths-ignore:
- '
.md'
- '.yml'
- '
.yaml'
- 'examples/*'
- '!.github/workflows/test.yml'

env:
GO111MODULE: on
GOPROXY: "https://proxy.golang.org"

jobs:
lint:
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
name: Run golangci-lint
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

text
- name: Setup Go
    uses: actions/setup-go@v5
    with:
      go-version: '^1.20'
      cache: false

  - name: Setup and run golangci-lint
    uses: golangci/golangci-lint-action@v9
    with:
      version: v2.13.2
      args: --timeout=5m -v -E=gocritic -E=misspell -E=revive -E=godot

  - name: Check Go formatting
    run: golangci-lint fmt --diff -E=gofumpt

test:
needs: lint
strategy:
fail-fast: false
matrix:
go: [1.19, 1.26]
os: [ubuntu-latest, macos-latest, windows-latest]
name: Go ${{ matrix.go }} @ ${{ matrix.os }}
runs-on: ${{ matrix.os}}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

text
- name: Setup Go
    uses: actions/setup-go@v5
    with:
      go-version: ${{ matrix.go }}

  - name: Print Go environment
    id: go-env
    run: |
      printf "Using go at: $(which go)\n"
      printf "Go version: $(go version)\n"
      printf "\n\nGo environment:\n\n"
      go env
      printf "\n\nSystem environment:\n\n"
      env
      # Calculate the short SHA1 hash of the git commit
      echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
      echo "GO_CACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT

  - name: Run unit tests and integrated tests
    run: go test -v -race -coverprofile="codecov.report" -covermode=atomic

  - name: Upload code coverage report to Codecov
    uses: codecov/codecov-action@v5
    with:
      files: ./codecov.report
      flags: unittests
      name: codecov-ants
      fail_ci_if_error: true
      verbose: true
    env:
      CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}