From 88aec09ddfc831fd1fba06608c4f82be2e49fed6 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Sat, 12 Dec 2015 04:16:10 -0800 Subject: [PATCH] client: fixes for govet -shadow This fixes for shadowed error variables found by go tip go tool vet. Fixes for https://github.com/coreos/etcd/issues/3954. --- client/auth_role.go | 12 +++++------- client/auth_user.go | 22 ++++++++++------------ 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/client/auth_role.go b/client/auth_role.go index e771db7f4..f410edbe0 100644 --- a/client/auth_role.go +++ b/client/auth_role.go @@ -115,14 +115,13 @@ func (r *httpAuthRoleAPI) ListRoles(ctx context.Context) ([]string, error) { if err != nil { return nil, err } - if err := assertStatusCode(resp.StatusCode, http.StatusOK); err != nil { + if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil { return nil, err } var userList struct { Roles []string `json:"roles"` } - err = json.Unmarshal(body, &userList) - if err != nil { + if err = json.Unmarshal(body, &userList); err != nil { return nil, err } return userList.Roles, nil @@ -218,17 +217,16 @@ func (r *httpAuthRoleAPI) modRole(ctx context.Context, req *authRoleAPIAction) ( if err != nil { return nil, err } - if err := assertStatusCode(resp.StatusCode, http.StatusOK); err != nil { + if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil { var sec authError - err := json.Unmarshal(body, &sec) + err = json.Unmarshal(body, &sec) if err != nil { return nil, err } return nil, sec } var role Role - err = json.Unmarshal(body, &role) - if err != nil { + if err = json.Unmarshal(body, &role); err != nil { return nil, err } return &role, nil diff --git a/client/auth_user.go b/client/auth_user.go index 9df1f294d..8c04baa34 100644 --- a/client/auth_user.go +++ b/client/auth_user.go @@ -78,9 +78,9 @@ func (s *httpAuthAPI) enableDisable(ctx context.Context, req httpAction) error { if err != nil { return err } - if err := assertStatusCode(resp.StatusCode, http.StatusOK, http.StatusCreated); err != nil { + if err = assertStatusCode(resp.StatusCode, http.StatusOK, http.StatusCreated); err != nil { var sec authError - err := json.Unmarshal(body, &sec) + err = json.Unmarshal(body, &sec) if err != nil { return err } @@ -179,9 +179,9 @@ func (u *httpAuthUserAPI) ListUsers(ctx context.Context) ([]string, error) { if err != nil { return nil, err } - if err := assertStatusCode(resp.StatusCode, http.StatusOK); err != nil { + if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil { var sec authError - err := json.Unmarshal(body, &sec) + err = json.Unmarshal(body, &sec) if err != nil { return nil, err } @@ -190,8 +190,7 @@ func (u *httpAuthUserAPI) ListUsers(ctx context.Context) ([]string, error) { var userList struct { Users []string `json:"users"` } - err = json.Unmarshal(body, &userList) - if err != nil { + if err = json.Unmarshal(body, &userList); err != nil { return nil, err } return userList.Users, nil @@ -221,9 +220,9 @@ func (u *httpAuthUserAPI) addRemoveUser(ctx context.Context, req *authUserAPIAct if err != nil { return err } - if err := assertStatusCode(resp.StatusCode, http.StatusOK, http.StatusCreated); err != nil { + if err = assertStatusCode(resp.StatusCode, http.StatusOK, http.StatusCreated); err != nil { var sec authError - err := json.Unmarshal(body, &sec) + err = json.Unmarshal(body, &sec) if err != nil { return err } @@ -280,17 +279,16 @@ func (u *httpAuthUserAPI) modUser(ctx context.Context, req *authUserAPIAction) ( if err != nil { return nil, err } - if err := assertStatusCode(resp.StatusCode, http.StatusOK); err != nil { + if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil { var sec authError - err := json.Unmarshal(body, &sec) + err = json.Unmarshal(body, &sec) if err != nil { return nil, err } return nil, sec } var user User - err = json.Unmarshal(body, &user) - if err != nil { + if err = json.Unmarshal(body, &user); err != nil { return nil, err } return &user, nil