keyringutil

package
v0.25.3 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 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 keyringutil stores values in the operating system keyring without being limited by the maximum size of a single keyring entry.

Windows Credential Manager limits each entry to 2560 bytes and the macOS Keychain (via go-keyring) to roughly 2900 bytes. Values larger than ChunkSize are split across several entries named "<service> #<n>", with the main entry holding a header that records the number of parts and a SHA-256 hash of the complete value. Smaller values are stored in a single entry exactly as go-keyring would store them, so existing entries remain readable.

Index

Constants

View Source
const (
	// ChunkSize is the largest value stored in a single keyring entry. It is
	// below the per-entry limits of Windows Credential Manager and the macOS
	// Keychain with room to spare.
	ChunkSize = 2000
)

Variables

View Source
var (
	// ErrNotFound is returned when no value is stored. It is the same error
	// returned by go-keyring so either may be checked with errors.Is.
	ErrNotFound = keyring.ErrNotFound

	// ErrIncomplete is returned, along with [ErrNotFound], when a value that
	// was split into parts is missing parts or does not match its hash, such
	// as when a write was interrupted
	ErrIncomplete = errors.New("stored value is incomplete")

	// ErrTooLarge is returned when a value would need more than the maximum
	// number of parts
	ErrTooLarge = errors.New("value is too large to store")
)

Functions

func Delete

func Delete(service, user string) error

Delete removes the value stored for service and user, including any parts. ErrNotFound is returned if no value was stored.

func Get

func Get(service, user string) (string, error)

Get returns the value stored for service and user. ErrNotFound is returned if no value is stored or a value split into parts is incomplete.

func Set

func Set(service, user, value string) error

Set stores value for service and user, replacing any existing value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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