4 ms·
The APIs that you as the programmer are supposed to invoke tend to be well-documented and fairly well-designed. But there's some parts in there I certainly wou
by edgyswingset 10y ago
The APIs that you as the programmer are supposed to invoke tend to be well-documented and fairly well-designed.
But there's some parts in there I certainly wouldn't call elegant. For example, if you trace function calls from http.Get() you end up in a lovely function called doFollowingRedirects()[0] which is where the actual request is made inside of a for {} loop.
Be it efficiency, some stylistic tendency I'm unaware of, or some contrived excuse that doesn't make any sense, at the end of the day I'm not likely to look for a function called doFollowingRedirects when I want to see where the initial (and likely only) request is made.
[0]: https://github.com/golang/go/blob/master/src/net/http/client.go#L430 https://github.com/golang/go/blob/master/src/net/http/client...
- tekacs 10y agoI read `doFollowingRedirects` with an elided comma - that is, 'do, following redirects (as you go)'. In that context, the function doesn't seem so surprising. If you take a look at the function `Do`[0], you'll notice it calls out to either 'send' or 'doFollowingRedirects' depending on whether it's a request that should 'do, following redirects' or simply 'send a single request'. Many HTTP libraries I've seen are structured around creating a request object and then handing it to a 'do request' function - the crime here at best seems to be the naming 'doFollowingRedirects', which can be read as 'do the subsequent redirects' which might make it seem odd that the first request was included in the for loop therein.