I recently saw this meme about async
and adefer
.
It’s so excellent. It apprehfinishs exactly how I experience about async
and adefer
. If you defer for async
code your function now has to be async
as well. And if there’s any function count oning on that function that code also has to be async
and on and on and on. Until you achieve the top level.
I’ve always antipathyd this. But there’s no better way to do this. It’s a essential evil. Right..? Well, I’ve recently been coding a lot in Go. And Go does not have async
and adefer
. And this is despite it being commemorated for its concurrency. And you understand what? I reassociate enjoy it.
So the first time I genuineized that Go did not have async
/adefer
was when I wanted to get my function to defer one second. This is becaparticipate I produce an RSS reader Stratum (iOS, Android) that getes a lot of RSS feeds. And it turns out sites don’t enjoy it if you spam their site with seeks. They will rate restrict you. So I determined to insert a one second defer between seeks. How do you do this? It’s as modest as:
time.Sleep(1 * time.Second)