4 ms·
I immediately noticed this as well. This API has flags for "asynchronous" requests, but Go style is to provide a blocking API, and let the caller decide to use
by evmar 11y ago
I immediately noticed this as well. This API has flags for "asynchronous" requests, but Go style is to provide a blocking API, and let the caller decide to use a goroutine if they need concurrency.
- XorNot 11y agoConstructing a channel (as it does though) is just pragmatic though and definitely not any less go-like. You get a channel - you can read from it until it's closed which is always safe. Go-routines are cheap so you don't care about the background details. For simplifying HTTP, this is great.
- levigross 11y agoOriginally the API was completely asynchronous (every "request" function returned a channel). I got a lot of feedback that I shouldn't do that, so I moved the asynchronous requests to specific functions e.g GetAsync and made the standard API synchronous.
- sagichmal 11y agoYou should go further, removing the async methods altogether. In Go, making sync APIs async is trivial and well-understood.