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

defaults

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 7 Imported by: 0

README

keyring-defaults

CI Go Reference

Default first-party provider list for github.com/lox/keyring/v2.

This module exists so applications can opt in to the common desktop and command-backed providers without adding those imports to the lightweight root keyring module.

Usage

go get github.com/lox/keyring-defaults
import (
	"context"

	defaults "github.com/lox/keyring-defaults"
	"github.com/lox/keyring/v2"
)

ctx := context.Background()

ring, err := keyring.Open(ctx,
	keyring.WithServiceName("example"),
	keyring.WithProviders(defaults.Providers()...),
)

Pass application-owned fallbacks as extra providers:

providers := defaults.Providers(
	keyring.FileProvider(
		keyring.FileDir("/path/to/keyring"),
		keyring.FilePrompt(keyring.FixedStringPrompt("passphrase")),
	),
)

Applications that need explicit macOS Keychain trust policy can override the default keychain provider without changing its position:

providers := defaults.Providers(
	defaults.KeychainTrustApplication(false),
	keyring.FileProvider(
		keyring.FileDir("/path/to/keyring"),
		keyring.FilePrompt(keyring.FixedStringPrompt("passphrase")),
	),
)

Providers returns providers in this order:

  1. Windows Credential Manager
  2. macOS Keychain
  3. Secret Service
  4. KWallet
  5. Linux keyctl
  6. pass
  7. any extra providers passed by the application

Unsupported platform providers return keyring.ErrUnavailable when opened, so keyring.Open can fall through to the next provider.

The encrypted file provider is intentionally not included by default because its directory and prompt are application policy. Pass keyring.FileProvider(...) to Providers when you want it as a fallback.

Development

go test ./...
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2 run

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeychainTrustApplication

func KeychainTrustApplication(enabled bool) keyring.Provider

KeychainTrustApplication returns a keychain provider with trust configured.

func Providers

func Providers(extra ...keyring.Provider) []keyring.Provider

Providers returns the default first-party provider order.

Types

This section is empty.

Jump to

Keyboard shortcuts

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