gist

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: AGPL-3.0 Imports: 13 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 gist keeps backups in a secret GitHub gist, reached with a personal access token: each backup is a file of its own, named by backup.Name, in the one gist whose description is Description. A secret gist is unlisted, not private: anyone with its address can read the sealed files in it.

Index

Constants

View Source
const Description = "SSHYard backup"

Description marks the gist SSHYard keeps its backups in.

Variables

View Source
var (
	// ErrToken reports an empty token, or one with spaces or line breaks.
	ErrToken = errors.New("gist: empty or malformed token")
	// ErrName reports a file name that is not a backup's.
	ErrName = errors.New("gist: not a backup file name")
	// ErrText reports data that is not UTF-8 text, which a gist cannot hold.
	ErrText = errors.New("gist: a gist holds text only")
)

Functions

This section is empty.

Types

type Gist

type Gist struct {
	Token string
	// ID is the gist's ID, "" until one is found or made.
	ID string
	// Bound is called, on the calling goroutine, with the ID once a gist
	// is found or made, so that it can be saved. It may be nil.
	Bound func(id string)
	// API is the REST API's root; "" is GitHub's.
	API string
	// HTTP is the client requests go through; nil is backup.Client(nil).
	HTTP *http.Client
}

Gist is the backup gist of the user a token belongs to.

func (*Gist) Check

func (g *Gist) Check(ctx context.Context) error

Check reaches the backup gist with the token, or, with none yet, the user's gists.

func (*Gist) Delete

func (g *Gist) Delete(ctx context.Context, name string) error

Delete removes a backup from the gist. Its earlier revisions keep it.

func (*Gist) Get

func (g *Gist) Get(ctx context.Context, name string) ([]byte, error)

Get reads one backup, from its raw address when the API cut it short.

func (*Gist) List

func (g *Gist) List(ctx context.Context) ([]backup.Object, error)

List is the backups in the gist, newest first; none without a gist.

func (*Gist) Put

func (g *Gist) Put(ctx context.Context, name string, data []byte) error

Put adds a backup to the gist, making the gist (secret) when there is none yet.

Jump to

Keyboard shortcuts

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