The Daily Go
Many suggest to use
Any item stored in the Pool may be removed automatically at any time without notification. If the Pool holds the only reference when this happens, the item might be deallocated.
#Note #Pool
Many suggest to use
sync.Pool
which is a fast, good implementation for temporary objects. But note that sync.Pool
does not guarantee that pooled objects are retained. Quoting from its doc:Any item stored in the Pool may be removed automatically at any time without notification. If the Pool holds the only reference when this happens, the item might be deallocated.
#Note #Pool
The Daily Go
Range and Close on Channels
A sender can close a channel to indicate that no more values will be sent. Receivers can test whether a channel has been closed by assigning a second parameter to the receive expression: after
ok is false if there are no more values to receive and the channel is closed.
The loop
Note: Only the sender should close a channel, never the receiver. Sending on a closed channel will cause a panic.
Another note: Channels aren't like files; you don't usually need to close them. Closing is only necessary when the receiver must be told there are no more values coming, such as to terminate a range loop.
#Note #Channel
Range and Close on Channels
A sender can close a channel to indicate that no more values will be sent. Receivers can test whether a channel has been closed by assigning a second parameter to the receive expression: after
v, ok := <-ch
ok is false if there are no more values to receive and the channel is closed.
The loop
for i := range c
receives values from the channel repeatedly until it is closed.Note: Only the sender should close a channel, never the receiver. Sending on a closed channel will cause a panic.
Another note: Channels aren't like files; you don't usually need to close them. Closing is only necessary when the receiver must be told there are no more values coming, such as to terminate a range loop.
#Note #Channel
The Daily Go
timenote is a tool to take notes with timestamps.
https://github.com/sascha-andres/timenote
#Note #TimeSeries
timenote is a tool to take notes with timestamps.
https://github.com/sascha-andres/timenote
#Note #TimeSeries
GitHub
sascha-andres/timenote
timenote is a tool to take notes with timestamps. You can choose between two different backends