API 参考取自源码中的 Go 文档注释,以英文书写。
package keychain
import "github.com/nsgo-dev/game/pkg/editor/keychain"概述
Package keychain stores secrets in the host OS keychain: macOS Keychain, the Freedesktop Secret Service on Linux, and Windows Credential Manager, with an in-memory Store for tests. It imports only the standard library.
索引
变量
var ErrNotFound = errors.New("keychain: credential not found in system keychain")ErrNotFound is returned by Store.Get when no secret is stored for the requested service and account.
类型
type Memory struct {
// contains filtered or unexported fields
}Memory is a thread-safe in-memory Store implementation for tests and sandboxed tooling.
func (m *Memory) Delete(service, account string) errorDelete removes any secret stored under (service, account) in memory.
func (m *Memory) Get(service, account string) (string, error)Get retrieves the secret stored under (service, account) in memory.
func (m *Memory) Len() intLen returns the number of entries currently stored in memory.
func (m *Memory) Set(service, account, secret string) errorSet stores secret under (service, account) in memory.
type Store interface {
Set(service, account, secret string) error
Get(service, account string) (string, error)
Delete(service, account string) error
}Store stores, retrieves, and removes secrets in the host OS keychain (macOS Keychain, Linux Secret Service, Windows Credential Manager) or an in-memory test store. Secrets must never be written into project files.
func Default() StoreDefault returns the platform's native system keychain implementation.