Deadlines and Timeouts:
Contexts can be associated with a deadline (a specific time) or a timeout (a duration). If the …
This is where I'll be sharing blogs about tech, art, must try food spots, &c!
I am forgetful and every so often have to revise compSci/cyber principles. I decided I will document my notes here under the tag 'flashcard' ⋆˚࿔
Sometimes you want a function to be able to read the room, to get context
about what is going on. For instance, if a certain function exits, you want all sub-processes to complete as well. Well, golang can’t read body language but it does have a context
package.
This package lets your code carry cancellation signals, deadlines, and request-scoped values across API boundaries and down into goroutines.
A context.Context
can carry a cancellation signal. When a context is canceled, all goroutines that are listening on its Done()
channel will be notified, allowing them to gracefully stop their operations. This is crucial for resource management and preventing goroutine leaks.
Contexts can be associated with a deadline (a specific time) or a timeout (a duration). If the …