mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client: consistently use defer for ensureReaderClosed
ensureReaderClosed was designed to be usable regardless if a response was nil (error) or non-nil (success). Some code-paths were optimized to avoid using a defer (which used to have an overhead), but the overhead of defer is neglectable in current versions of Go, and some of these optimizations made the logic more complicated (and err-prone). This patch switches to use a defer for all places. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -16,6 +16,6 @@ func (cli *Client) SwarmUpdate(ctx context.Context, version swarm.Version, swarm
|
||||
query.Set("rotateManagerToken", strconv.FormatBool(flags.RotateManagerToken))
|
||||
query.Set("rotateManagerUnlockKey", strconv.FormatBool(flags.RotateManagerUnlockKey))
|
||||
resp, err := cli.post(ctx, "/swarm/update", query, swarm, nil)
|
||||
ensureReaderClosed(resp)
|
||||
defer ensureReaderClosed(resp)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user