GitHubComeçar

A referência da API é gerada a partir dos comentários de documentação Go no código-fonte e está escrita em inglês.

package keychain

import "github.com/nsgo-dev/game/pkg/editor/keychain"

Visão geral

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.

Índice

Variáveis

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.

var ErrUnavailable = errors.New("keychain: system keychain unavailable on this platform")

ErrUnavailable is returned when the host platform does not expose a desktop system keychain.

Tipos

type Memory struct {
	// contains filtered or unexported fields
}

Memory is a thread-safe in-memory Store implementation for tests and sandboxed tooling.

func NewMemory() *Memory

NewMemory constructs an empty in-memory Store.

func (m *Memory) Delete(service, account string) error

Delete 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() int

Len returns the number of entries currently stored in memory.

func (m *Memory) Set(service, account, secret string) error

Set 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() Store

Default returns the platform's native system keychain implementation.