keychain

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

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.

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
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.

Functions

This section is empty.

Types

type Memory

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

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

func NewMemory

func NewMemory() *Memory

NewMemory constructs an empty in-memory Store.

func (*Memory) Delete

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

Delete removes any secret stored under (service, account) in memory.

func (*Memory) Get

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

Get retrieves the secret stored under (service, account) in memory.

func (*Memory) Len

func (m *Memory) Len() int

Len returns the number of entries currently stored in memory.

func (*Memory) Set

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

Set stores secret under (service, account) in memory.

type Store

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

func Default() Store

Default returns the platform's native system keychain implementation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL