localdata

package
v1.17.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package local_data provides a keyring implementation that stores data in the system keyring. If the keyring is not available, it falls back to storing the data in a file.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("data not found")

ErrNotFound is the expected error if the data isn't found in the keyring or in the file.

Functions

This section is empty.

Types

type Keyring

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

func New

func New(serviceName, backupFile string) *Keyring

New creates a new keyring. serviceName is the name of the service that will be used to store the data. backupFile is the name of the file that will be used to store the data if the keyring is not available. The file is stored in the user's home directory, in a file named after the key.

func (*Keyring) Delete

func (k *Keyring) Delete(key string) error

Delete removes the data from the keyring. If the keyring is not available, it falls back to removing the data from a file.

func (*Keyring) Get

func (k *Keyring) Get(key string) (string, error)

Get retrieves the data from the keyring. If the keyring is not available, it falls back to retrieving the data from a file.

func (*Keyring) Save

func (k *Keyring) Save(key, data string) error

Save stores the data in the keyring. If the keyring is not available, it falls back to storing the data in a file. The file is stored in the user's home directory, in a file named after the key.

Jump to

Keyboard shortcuts

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