Merge lp:~dave-cheney/goose/100-fix-vet-errors into lp:goose

Proposed by Dave Cheney
Status: Merged
Approved by: Dave Cheney
Approved revision: 127
Merged at revision: 124
Proposed branch: lp:~dave-cheney/goose/100-fix-vet-errors
Merge into: lp:goose
Diff against target: 123 lines (+19/-25)
6 files modified
nova/json.go (+8/-9)
testservices/cmd/main.go (+1/-2)
testservices/identityservice/keypair.go (+4/-6)
testservices/identityservice/userpass.go (+4/-6)
testservices/novaservice/service_http.go (+1/-1)
tools/secgroup-delete-all/main_test.go (+1/-1)
To merge this branch: bzr merge lp:~dave-cheney/goose/100-fix-vet-errors
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+219781@code.launchpad.net

Commit message

goose: fix vet errors

* fix several printf errors
* address unreachable code warnings. Rewrote branches to avoid unreachable code while being compatible with Go 1.0

Description of the change

goose: fix vet errors

* fix several printf errors
* address unreachable code warnings. Rewrote branches to avoid unreachable code while being compatible with Go 1.0

https://codereview.appspot.com/96360045/

To post a comment you must log in.
Revision history for this message
Dave Cheney (dave-cheney) wrote :
Download full text (5.2 KiB)

Reviewers: mp+219781_code.launchpad.net,

Message:
Please take a look.

Description:
goose: fix vet errors

* fix several printf errors
* address unreachable code warnings. Rewrote branches to avoid
unreachable code while being compatible with Go 1.0

https://code.launchpad.net/~dave-cheney/goose/100-fix-vet-errors/+merge/219781

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/96360045/

Affected files (+21, -25 lines):
   A [revision details]
   M nova/json.go
   M testservices/cmd/main.go
   M testservices/identityservice/keypair.go
   M testservices/identityservice/userpass.go
   M testservices/novaservice/service_http.go
   M tools/secgroup-delete-all/main_test.go

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-20140513085629-73yp1ik7s2wh2u5o
+New revision: <email address hidden>

Index: nova/json.go
=== modified file 'nova/json.go'
--- nova/json.go 2013-06-26 02:55:42 +0000
+++ nova/json.go 2014-05-16 06:16:12 +0000
@@ -43,16 +43,15 @@
   if err := json.Unmarshal(b, &out); err != nil {
    return "", err
   }
- if val, ok := out[tag]; !ok {
+ val, ok := out[tag]
+ if !ok {
    return "", nil
- } else {
- if floatVal, ok := val.(float64); ok {
- return fmt.Sprint(int(floatVal)), nil
- } else {
- return fmt.Sprint(val), nil
- }
- }
- panic("unreachable")
+ }
+ floatVal, ok := val.(float64)
+ if ok {
+ return fmt.Sprint(int(floatVal)), nil
+ }
+ return fmt.Sprint(val), nil
  }

  // appendJSON marshals the given attribute value and appends it as an
encoded value to the given json data.

Index: testservices/cmd/main.go
=== modified file 'testservices/cmd/main.go'
--- testservices/cmd/main.go 2013-01-24 03:15:19 +0000
+++ testservices/cmd/main.go 2014-05-16 06:10:03 +0000
@@ -38,7 +38,6 @@
  var users userValues

  func init() {
-
   gnuflag.Var(&users, "user", "supply to add a user to the identity
provider. Can be supplied multiple times. Should be of the form
\"user:secret:token\".")
  }

@@ -59,7 +58,7 @@
   gnuflag.Parse(true)
   p, ok := providerMap[*provider]
   if !ok {
- log.Fatalf("No such provider: %s, pick one of: %v", provider,
providers())
+ log.Fatalf("No such provider: %s, pick one of: %v", *provider,
providers())
   }
   mux := http.NewServeMux()
   p.SetupHTTP(mux)

Index: testservices/identityservice/keypair.go
=== modified file 'testservices/identityservice/keypair.go'
--- testservices/identityservice/keypair.go 2013-05-21 01:07:40 +0000
+++ testservices/identityservice/keypair.go 2014-05-16 06:12:51 +0000
@@ -90,15 +90,13 @@
    u.ReturnFailure(w, http.StatusInternalServerError, err.Error())
    return
   }
- if content, err := json.Marshal(res); err != nil {
+ content, err := json.Marshal(res)
+ if err != nil {
    u.ReturnFailure(w, http.StatusInternalServerError, err.Error())
    return
- } else {
- w.WriteHeader(http.StatusOK)
- w.Write(content)
- return
   }
- panic("unreachable")
+ w.WriteHeader(http.StatusOK)
+ w.Write(content)
  }

  func (u *KeyPair) ...

Read more...

Revision history for this message
Andrew Wilkins (axwalk) wrote :

On 2014/05/16 06:17:54, dfc wrote:
> Please take a look.

LGTM

https://codereview.appspot.com/96360045/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'nova/json.go'
--- nova/json.go 2013-06-26 02:55:42 +0000
+++ nova/json.go 2014-05-16 06:17:31 +0000
@@ -43,16 +43,15 @@
43 if err := json.Unmarshal(b, &out); err != nil {43 if err := json.Unmarshal(b, &out); err != nil {
44 return "", err44 return "", err
45 }45 }
46 if val, ok := out[tag]; !ok {46 val, ok := out[tag]
47 if !ok {
47 return "", nil48 return "", nil
48 } else {49 }
49 if floatVal, ok := val.(float64); ok {50 floatVal, ok := val.(float64)
50 return fmt.Sprint(int(floatVal)), nil51 if ok {
51 } else {52 return fmt.Sprint(int(floatVal)), nil
52 return fmt.Sprint(val), nil53 }
53 }54 return fmt.Sprint(val), nil
54 }
55 panic("unreachable")
56}55}
5756
58// appendJSON marshals the given attribute value and appends it as an encoded value to the given json data.57// appendJSON marshals the given attribute value and appends it as an encoded value to the given json data.
5958
=== modified file 'testservices/cmd/main.go'
--- testservices/cmd/main.go 2013-01-24 03:15:19 +0000
+++ testservices/cmd/main.go 2014-05-16 06:17:31 +0000
@@ -38,7 +38,6 @@
38var users userValues38var users userValues
3939
40func init() {40func init() {
41
42 gnuflag.Var(&users, "user", "supply to add a user to the identity provider. Can be supplied multiple times. Should be of the form \"user:secret:token\".")41 gnuflag.Var(&users, "user", "supply to add a user to the identity provider. Can be supplied multiple times. Should be of the form \"user:secret:token\".")
43}42}
4443
@@ -59,7 +58,7 @@
59 gnuflag.Parse(true)58 gnuflag.Parse(true)
60 p, ok := providerMap[*provider]59 p, ok := providerMap[*provider]
61 if !ok {60 if !ok {
62 log.Fatalf("No such provider: %s, pick one of: %v", provider, providers())61 log.Fatalf("No such provider: %s, pick one of: %v", *provider, providers())
63 }62 }
64 mux := http.NewServeMux()63 mux := http.NewServeMux()
65 p.SetupHTTP(mux)64 p.SetupHTTP(mux)
6665
=== modified file 'testservices/identityservice/keypair.go'
--- testservices/identityservice/keypair.go 2013-05-21 01:07:40 +0000
+++ testservices/identityservice/keypair.go 2014-05-16 06:17:31 +0000
@@ -90,15 +90,13 @@
90 u.ReturnFailure(w, http.StatusInternalServerError, err.Error())90 u.ReturnFailure(w, http.StatusInternalServerError, err.Error())
91 return91 return
92 }92 }
93 if content, err := json.Marshal(res); err != nil {93 content, err := json.Marshal(res)
94 if err != nil {
94 u.ReturnFailure(w, http.StatusInternalServerError, err.Error())95 u.ReturnFailure(w, http.StatusInternalServerError, err.Error())
95 return96 return
96 } else {
97 w.WriteHeader(http.StatusOK)
98 w.Write(content)
99 return
100 }97 }
101 panic("unreachable")98 w.WriteHeader(http.StatusOK)
99 w.Write(content)
102}100}
103101
104func (u *KeyPair) generateAccessResponse(userInfo *UserInfo) (*AccessResponse, error) {102func (u *KeyPair) generateAccessResponse(userInfo *UserInfo) (*AccessResponse, error) {
105103
=== modified file 'testservices/identityservice/userpass.go'
--- testservices/identityservice/userpass.go 2013-06-24 04:26:54 +0000
+++ testservices/identityservice/userpass.go 2014-05-16 06:17:31 +0000
@@ -222,15 +222,13 @@
222 u.ReturnFailure(w, http.StatusInternalServerError, err.Error())222 u.ReturnFailure(w, http.StatusInternalServerError, err.Error())
223 return223 return
224 }224 }
225 if content, err := json.Marshal(res); err != nil {225 content, err := json.Marshal(res)
226 if err != nil {
226 u.ReturnFailure(w, http.StatusInternalServerError, err.Error())227 u.ReturnFailure(w, http.StatusInternalServerError, err.Error())
227 return228 return
228 } else {
229 w.WriteHeader(http.StatusOK)
230 w.Write(content)
231 return
232 }229 }
233 panic("All paths should have already returned")230 w.WriteHeader(http.StatusOK)
231 w.Write(content)
234}232}
235233
236func (u *UserPass) generateAccessResponse(userInfo *UserInfo) (*AccessResponse, error) {234func (u *UserPass) generateAccessResponse(userInfo *UserInfo) (*AccessResponse, error) {
237235
=== modified file 'testservices/novaservice/service_http.go'
--- testservices/novaservice/service_http.go 2014-05-02 01:12:04 +0000
+++ testservices/novaservice/service_http.go 2014-05-16 06:17:31 +0000
@@ -898,7 +898,7 @@
898 // TODO: Use a proper helper and sane error type898 // TODO: Use a proper helper and sane error type
899 return &errorResponse{899 return &errorResponse{
900 http.StatusBadRequest,900 http.StatusBadRequest,
901 fmt.Sprintf(`{"badRequest": {"message": "This rule already exists in group %d", "code": 400}}`, group.Id),901 fmt.Sprintf(`{"badRequest": {"message": "This rule already exists in group %s", "code": 400}}`, group.Id),
902 "application/json; charset=UTF-8",902 "application/json; charset=UTF-8",
903 "rule already exists",903 "rule already exists",
904 nil,904 nil,
905905
=== modified file 'tools/secgroup-delete-all/main_test.go'
--- tools/secgroup-delete-all/main_test.go 2014-05-01 18:04:32 +0000
+++ tools/secgroup-delete-all/main_test.go 2014-05-16 06:17:31 +0000
@@ -75,7 +75,7 @@
75func deleteGroupError(s hook.ServiceControl, args ...interface{}) error {75func deleteGroupError(s hook.ServiceControl, args ...interface{}) error {
76 groupId := args[0].(string)76 groupId := args[0].(string)
77 if groupId == doNotDelete.Id {77 if groupId == doNotDelete.Id {
78 return fmt.Errorf("cannot delete group %d", groupId)78 return fmt.Errorf("cannot delete group %s", groupId)
79 }79 }
80 return nil80 return nil
81}81}

Subscribers

People subscribed via source and target branches