Help us shape the future of Go! Take the 2026 Go Developer Survey

credstore

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store handles credential storage with keyring preference and file fallback.

func NewStore

func NewStore(opts StoreOptions) *Store

NewStore creates a credential store. It probes the system keyring and falls back to file storage if unavailable.

func (*Store) Delete

func (s *Store) Delete(key string) error

Delete removes credentials for the given key.

func (*Store) FallbackWarning

func (s *Store) FallbackWarning() string

FallbackWarning returns a warning message if the store fell back to file storage, or empty string if using keyring.

func (*Store) Load

func (s *Store) Load(key string) ([]byte, error)

Load retrieves credentials for the given key.

func (*Store) MigrateToKeyring

func (s *Store) MigrateToKeyring() error

MigrateToKeyring migrates credentials from file to keyring. No-op if keyring is not available.

func (*Store) Save

func (s *Store) Save(key string, data []byte) error

Save stores credentials for the given key.

func (*Store) UsingKeyring

func (s *Store) UsingKeyring() bool

UsingKeyring returns true if the store is using the system keyring.

type StoreOptions

type StoreOptions struct {
	// ServiceName is the keyring service name (e.g., "basecamp", "fizzy").
	ServiceName string

	// DisableEnvVar is the env var name that disables keyring (e.g., "BASECAMP_NO_KEYRING").
	// When set to any non-empty value, forces file-based storage.
	DisableEnvVar string

	// FallbackDir is the directory for file-based credential storage.
	FallbackDir string
}

StoreOptions configures credential storage.

Jump to

Keyboard shortcuts

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