keybase / go-keychain

Golang keychain package for iOS and macOS
MIT License
573 stars 120 forks source link

secretservice.replaceBehavior is not exported #71

Closed ringerc closed 2 years ago

ringerc commented 3 years ago

The type secretservice.replaceBehavior is not exported, though constants secretservice.ReplaceBehaviorDoNotReplace and secretservice.ReplaceBehaviorReplace are.

This may be a golang newbie problem, but this appears to prevent the use of the flag as a variable, e.g.

        replaceFlag := secretservice.ReplaceBehaviorDoNotReplace
        if replaceIfExists {
                replaceFlag = secretservice.ReplaceBehaviorReplace
        }
        _, err = srv.CreateItem(collection, secreteservice.NewSecretProperties("label", makeAPropertiesMap()), password, replaceFlag)

as the type of replaceFlag to decay to int, resulting in error

cannot use replaceFlag (type int) as type secretservice.replaceBehavior in argument to srv.CreateItem

If the initialization of replaceFlag is explicitly typed secretservice.replaceBehavior then the build will fail with cannot refer to unexported name secretservice.replaceBehavior. Same if an explicit cast is used when passing the argument.

Unless this is me being a golang ignoramus, it seems like secretservice.replaceBehavior should be exported as secretservice.ReplaceBehavior instead.

joshblum commented 2 years ago

fixed in #75