Use *_test packages to make examples copy-pasteable#124
Merged
Conversation
The main reason for this PR is to make the examples in documentation
copy-pastable.
For example, the pool example before this change:
```go
p := New().WithMaxGoroutines(3)
for i := 0; i < 5; i++ {
p.Go(func() {
fmt.Println("conc")
})
}
p.Wait()
```
and after:
```go
p := pool.New().WithMaxGoroutines(3) // has package name
for i := 0; i < 5; i++ {
p.Go(func() {
fmt.Println("conc")
})
}
p.Wait()
```
There are some additional benefits.
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Codecov Report
@@ Coverage Diff @@
## main #124 +/- ##
=======================================
Coverage 99.31% 99.31%
=======================================
Files 12 12
Lines 441 441
=======================================
Hits 438 438
Misses 3 3 📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today! |
camdencheek
approved these changes
Nov 12, 2023
camdencheek
left a comment
Contributor
There was a problem hiding this comment.
Great idea! Neat trick -- that's a new one for me. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The main reason for this PR was to make the examples in documentation
copy-pasteable, but there are some additional benefits too.
For example, the pool example before this change:
and after:
The function
defaultMaxGoroutinesiniterpackage had to be exported because it was used from the tests.