auto

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package auto picks the credential backend for the platform it is built for.

It exists for multiplatform CLIs that just want "whatever this machine has". Code that knows its environment should skip it and inject the backend directly — a browser application imports keyring/browser, not this package.

Index

Constants

View Source
const (
	// ErrGoModNotFound is returned when no go.mod exists in dir or any parent.
	ErrGoModNotFound = keyring.Error("keyring/auto: no go.mod found walking up from the given directory")
	// ErrNoModuleDirective is returned when go.mod has no `module` line.
	ErrNoModuleDirective = keyring.Error("keyring/auto: go.mod has no module directive")
)

Variables

This section is empty.

Functions

func New

func New() *keyring.KeyManager

New is keyring.New with the platform's provider already chosen.

func Provider

func Provider() keyring.Provider

Provider returns the Secret Service backend.

Types

type Keyring

type Keyring = keyring.Keyring

Keyring is an alias so callers need only this import.

func NewKeyring

func NewKeyring(service string) (*Keyring, error)

NewKeyring is keyring.NewKeyring with the platform's provider already chosen.

func OpenForModule added in v0.2.3

func OpenForModule(dir string) (*Keyring, error)

OpenForModule opens (auto-selecting the platform's provider, same as OpenKeyring) a Keyring scoped to the Go module found by walking up from dir — pass "." for the current working directory. The module's own path is the service namespace: it is already globally unique, so two different projects' identically named keys never collide, and no project has to remember to declare a service name of its own.

func OpenKeyring

func OpenKeyring(service string) *Keyring

OpenKeyring is keyring.OpenKeyring with the platform's provider already chosen.

Jump to

Keyboard shortcuts

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