Not sure if it was your intention, but your weekly update case will reset every time there is a manual update. I avoid time.After for recurring tasks in a select loop for this reason.
time.Ticker is great if you want to repeat the task at approximately the same interval. time.Timer is what I use when I want the task to repeat a certain time after the previous task has finished. You can also conveniently use timer.Reset(0) to trigger an immediate tick.
The funny thing is that I knew it, but wrote `for v := range array` anyway at least a few times! My point is, it's not very intuitive. Thankfully, the compiler catches that, unless it's `[]int`.
The idea is it's `for k := range object` to iterate over the keys, and `for k, v := range object` to iterate over the keys and values, whether the object is a slice, array, map or string. The only exceptional case is a channel, which has no indices/keys.
> "Slicing past the end of array results in a runtime panic. Ignoring out of bound indices is more convenient (and consistent with how other languages handle this)."
11 comments
[ 2.9 ms ] story [ 31.8 ms ] threadCan I use it? Is the source code available?
I think its purely closed source based on the article.
That being said, we plan to extract and free common code as we use Go for more projects. We love free / open source software!
time.Ticker is great if you want to repeat the task at approximately the same interval. time.Timer is what I use when I want the task to repeat a certain time after the previous task has finished. You can also conveniently use timer.Reset(0) to trigger an immediate tick.
`time.Ticker` looks handy, I will definitely use it for another project.
http://play.golang.org/p/JZZ40FMOMz
Ignoring logic bugs sounds like a horrible idea