mirror of https://github.com/helm/helm
While working on #6519, it took me hours to figure out why the error returned from `Save` was nil even though `writeTarContents` returned a non-nil error. I fixed the bug as part of that PR; the purpose of this commit is to prevent it from happening again. What made me (as a Go beginner) so confused was the impression that there was only ever one `err` variable, global to the entire `Save` function, when in fact there were also several local ones shadowing it. (I thought := could be used to reassign an existing variable.) This commit makes it clear that any `err` defined locally in the last `if` statement will not be returned at the end, and hence must be explicitly returned in the body of said `if` statement. (This commit initially was larger; see #6669.) Signed-off-by: Simon Alling <alling.simon@gmail.com>pull/6669/head
parent
3edad39e08
commit
a7c285bf7e
Loading…
Reference in new issue