@@ -93,15 +93,14 @@ func (h Osxkeychain) Get(serverURL string) (string, string, error) {
9393 errMsg := C .keychain_get (s , & usernameLen , & username , & secretLen , & secret )
9494 if errMsg != nil {
9595 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 :
9898 return "" , "" , credentials .NewErrCredentialsNotFound ()
99- }
100- if goMsg == errInteractionNotAllowed {
99+ case errInteractionNotAllowed :
101100 return "" , "" , ErrInteractionNotAllowed
101+ default :
102+ return "" , "" , errors .New (goMsg )
102103 }
103-
104- return "" , "" , errors .New (goMsg )
105104 }
106105
107106 user := C .GoStringN (username , C .int (usernameLen ))
@@ -124,15 +123,14 @@ func (h Osxkeychain) List() (map[string]string, error) {
124123 defer C .freeListData (& acctsC , listLenC )
125124 if errMsg != nil {
126125 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 :
129128 return make (map [string ]string ), nil
130- }
131- if goMsg == errInteractionNotAllowed {
129+ case errInteractionNotAllowed :
132130 return nil , ErrInteractionNotAllowed
131+ default :
132+ return nil , errors .New (goMsg )
133133 }
134-
135- return nil , errors .New (goMsg )
136134 }
137135
138136 var listLen int
0 commit comments