keyring

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package keyring provides a small, dependency-free secret store backed by the operating system's native credential tooling: the `security` keychain CLI on macOS and `secret-tool` (libsecret) on Linux. It stores a single secret string per (service, account). Windows and other platforms report unsupported.

It shells out to the OS tools rather than taking a third-party dependency. On macOS the secret is passed to `security` as an argument, so it is briefly visible to other processes via the process list; on Linux the secret is passed over stdin and is not exposed in the argument vector. Callers that need to keep a secret out of the process list on macOS should prefer the file backend.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = errors.New("keyring: no OS keyring backend on this platform")

ErrUnsupported is returned when no OS keyring backend is available for the current platform.

Functions

This section is empty.

Types

type Keyring

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

Keyring is an OS-native secret store.

func New

func New() *Keyring

New returns a Keyring for the current platform.

func (*Keyring) Available

func (k *Keyring) Available() bool

Available reports whether this platform has a supported keyring backend. The backing tool (`secret-tool` on Linux) must also be installed; a missing tool surfaces as an error from Get/Set/Delete.

func (*Keyring) Delete

func (k *Keyring) Delete(service, account string) (bool, error)

Delete removes the entry under (service, account), reporting whether one existed.

func (*Keyring) Get

func (k *Keyring) Get(service, account string) (string, bool, error)

Get returns the secret stored under (service, account). The bool is false when no entry exists (which is not an error).

func (*Keyring) Set

func (k *Keyring) Set(service, account, secret string) error

Set stores secret under (service, account), replacing any existing value.

Jump to

Keyboard shortcuts

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