Skip to content

Commit

Permalink
fix: fix detect of ErrKeyNotFound error on non-english windows system
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey19 committed Mar 5, 2021
1 parent 7209b11 commit 21dc80d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions wincred.go
Expand Up @@ -4,10 +4,13 @@ package keyring

import (
"strings"
"syscall"

"github.com/danieljoos/wincred"
)

const elementNotFoundError = syscall.Errno(1168)

type windowsKeyring struct {
name string
prefix string
Expand Down Expand Up @@ -35,7 +38,7 @@ func init() {
func (k *windowsKeyring) Get(key string) (Item, error) {
cred, err := wincred.GetGenericCredential(k.credentialName(key))
if err != nil {
if err.Error() == "Element not found." {
if err == elementNotFoundError {
return Item{}, ErrKeyNotFound
}
return Item{}, err
Expand Down Expand Up @@ -65,7 +68,7 @@ func (k *windowsKeyring) Set(item Item) error {
func (k *windowsKeyring) Remove(key string) error {
cred, err := wincred.GetGenericCredential(k.credentialName(key))
if err != nil {
if err.Error() == "Element not found." {
if err == elementNotFoundError {
return ErrKeyNotFound
}
return err
Expand Down

0 comments on commit 21dc80d

Please sign in to comment.