Skip to content

Commit

Permalink
Merge pull request #43 from pluralistix/master
Browse files Browse the repository at this point in the history
"Element not found." does not work on non-english machines
  • Loading branch information
szuecs authored Jan 21, 2020
2 parents 91fe8ab + 605605b commit 6675570
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions keyring_windows.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package keyring

import "github.com/danieljoos/wincred"

const errNotFound = "Element not found."
import (
"github.com/danieljoos/wincred"
"syscall"
)

type windowsKeychain struct{}

// Get gets a secret from the keyring given a service name and a user.
func (k windowsKeychain) Get(service, username string) (string, error) {
cred, err := wincred.GetGenericCredential(k.credName(service, username))
if err != nil {
if err.Error() == errNotFound {
if err == syscall.ERROR_NOT_FOUND {
return "", ErrNotFound
}
return "", err
Expand All @@ -32,7 +33,7 @@ func (k windowsKeychain) Set(service, username, password string) error {
func (k windowsKeychain) Delete(service, username string) error {
cred, err := wincred.GetGenericCredential(k.credName(service, username))
if err != nil {
if err.Error() == errNotFound {
if err == syscall.ERROR_NOT_FOUND {
return ErrNotFound
}
return err
Expand Down

0 comments on commit 6675570

Please sign in to comment.