file

package
v1.6.5 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 11 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 file is the provider of credentials which are environment variables, or are kept in a file of JSON, which only its user can read, so credentials which are set, such as how a connector's server is signed in to, are kept once the process ends

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

File is the provider of credentials which are environment variables, or are in its file. The file is read each time, and written to a temporary file, which is renamed to it, so it's never written partly. It's safe to use concurrently.

func New

func New(path string) (*File, error)

New returns the provider of credentials which are environment variables, or are in the file with the path, whose directory is created, when it doesn't exist

func (*File) Delete

func (f *File) Delete(_ context.Context, key string) error

Delete deletes the credential with the key from the file, or does nothing when there's none. An environment variable isn't changed.

func (*File) Expand

func (f *File) Expand(ctx context.Context, value string) (string, error)

Expand replaces each placeholder with the credential it names, which must exist, and returns ErrNotFound, with each which doesn't

func (*File) Get

func (f *File) Get(ctx context.Context, key string) (string, error)

Get returns the environment variable with the key, when it's set, or else the credential in the file, or ErrNotFound when there's neither

func (*File) Set

func (f *File) Set(_ context.Context, key, value string) error

Set sets the credential with the key in the file, keeping the others

Jump to

Keyboard shortcuts

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