@@ -93,15 +93,14 @@ func (h Osxkeychain) Get(serverURL string) (string, string, error) {
93
93
errMsg := C .keychain_get (s , & usernameLen , & username , & secretLen , & secret )
94
94
if errMsg != nil {
95
95
defer C .free (unsafe .Pointer (errMsg ))
96
- goMsg := C .GoString (errMsg )
97
- if goMsg == errCredentialsNotFound {
96
+ switch goMsg := C .GoString (errMsg ); goMsg {
97
+ case errCredentialsNotFound :
98
98
return "" , "" , credentials .NewErrCredentialsNotFound ()
99
- }
100
- if goMsg == errInteractionNotAllowed {
99
+ case errInteractionNotAllowed :
101
100
return "" , "" , ErrInteractionNotAllowed
101
+ default :
102
+ return "" , "" , errors .New (goMsg )
102
103
}
103
-
104
- return "" , "" , errors .New (goMsg )
105
104
}
106
105
107
106
user := C .GoStringN (username , C .int (usernameLen ))
@@ -124,15 +123,14 @@ func (h Osxkeychain) List() (map[string]string, error) {
124
123
defer C .freeListData (& acctsC , listLenC )
125
124
if errMsg != nil {
126
125
defer C .free (unsafe .Pointer (errMsg ))
127
- goMsg := C .GoString (errMsg )
128
- if goMsg == errCredentialsNotFound {
126
+ switch goMsg := C .GoString (errMsg ); goMsg {
127
+ case errCredentialsNotFound :
129
128
return make (map [string ]string ), nil
130
- }
131
- if goMsg == errInteractionNotAllowed {
129
+ case errInteractionNotAllowed :
132
130
return nil , ErrInteractionNotAllowed
131
+ default :
132
+ return nil , errors .New (goMsg )
133
133
}
134
-
135
- return nil , errors .New (goMsg )
136
134
}
137
135
138
136
var listLen int
0 commit comments