feat: add semaphore
parent
0ffbcde1c3
commit
52c4b9f3ad
|
@ -61,7 +61,7 @@ eg.Go(func() error {
|
|||
if err := eg.Wait(); err != nil {
|
||||
// Handle error
|
||||
}
|
||||
</code></pre><h2>External libs</h2><h3>No need <code>vendor</code></h3><p>Only need if you need something from <code>vendor</code>, to generate mock or something else.<h3>Use <code>build.go</code> to include build tools in go.mod</h3><p>To easily control version of build tools.<p>For example <code>build.go</code>:<pre><code class=language-go>//go:build tools
|
||||
</code></pre><h3>Use <a href=https://pkg.go.dev/golang.org/x/sync/semaphore>semaphore</a> when need to implement WorkerPool</h3><p>Please don't use external libs for WorkerPool, I don't want to deal with dependency hell.<h2>External libs</h2><h3>No need <code>vendor</code></h3><p>Only need if you need something from <code>vendor</code>, to generate mock or something else.<h3>Use <code>build.go</code> to include build tools in go.mod</h3><p>To easily control version of build tools.<p>For example <code>build.go</code>:<pre><code class=language-go>//go:build tools
|
||||
// +build tools
|
||||
|
||||
package main
|
||||
|
|
|
@ -142,6 +142,10 @@ if err := eg.Wait(); err != nil {
|
|||
}
|
||||
```
|
||||
|
||||
### Use [semaphore](https://pkg.go.dev/golang.org/x/sync/semaphore) when need to implement WorkerPool
|
||||
|
||||
Please don't use external libs for WorkerPool, I don't want to deal with dependency hell.
|
||||
|
||||
## External libs
|
||||
|
||||
### No need `vendor`
|
||||
|
|
Loading…
Reference in New Issue