Comments (6)
I'm aware of this but don't want to complicate these examples to handle these "leak", especially since the programs by design exit very quickly (:
from gobyexample.
I think you meant the "Rate Limiting" example. But, yes, came here to say the same.
go func() {
for t := range time.Tick(time.Millisecond * 200) {
burstyLimiter <- t
}
}()
This is going to hang on channel write when the caller stops reading from burstyLimiter
.
from gobyexample.
I hope that the decision to close this can be revisited.
The current code on the site can easily cause a memory leak when used as-is from within a larger program that is a long-running service, say.
The fix is actually not that complicated and is similar to the Tickers example in the documentation.
from gobyexample.
I strongly advise to change this. A lot of people use this example as a coding tip, and producing a goroutine leak is quite serious and very difficult to track.
from gobyexample.
@dbenders This has been superseded by the discussion in #206
from gobyexample.
I just found leaks in our production code leading back to this example (it had been copied by someone who wanted to run code regularly and Google led them here). While the examples are quickly running, this code does spread into real code and sometimes makes its way past code reviews.
from gobyexample.
Related Issues (20)
- Allow copying HOT 1
- Add example: Operaions on closed channels HOT 1
- Shell output doesn't match program output
- Go by Example: WaitGroups: fmt.Print not safe for parallel output HOT 1
- Default number generator is no longer deterministic HOT 1
- update random numbers example to use `v2` after 1.22 is released
- Go by Example: For - cannot range over X (untyped int constant) HOT 1
- Time formatting example does not compile HOT 2
- Suggestion: Add an example for using iota to make enum-like constants
- Incorrect code example in official documentation eg. usage of range HOT 1
- Add example of type assertions HOT 1
- Fix InvalidRangeExpr error
- Adding Go version requirement to certain new features in the language. HOT 1
- Incorrect example for enum HOT 1
- translating to Arabic HOT 2
- Local Variable Captured by Func Literal in `waitgroups` Example HOT 1
- cannot range over 3 (untyped int constant)compilerInvalidRangeExpr HOT 3
- Nothing big just a typo HOT 1
- Believe the for range loop is incorrectly referencing an integer HOT 1
- Improve explanation of constructor functions for structs HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gobyexample.