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

hooks

package
v1.71.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package hooks runs the shell commands a backup is wrapped in.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Redirect

func Redirect(output string) string

Redirect returns the directory a pre hook asked the walk to read instead of the configured root, given as a GOBACK_ROOT=<dir> line on its stdout. The last such line wins; "" means no redirect.

Types

type Runner

type Runner struct {
	Pre  string
	Post string
	// Timeout bounds each hook; 0 means none.
	Timeout time.Duration
	// Stdout and Stderr receive the hooks' output; nil means the process's.
	Stdout io.Writer
	Stderr io.Writer
	// Logger is where the runner reports; nil means slog.Default.
	Logger *slog.Logger
}

Runner runs a backup's pre and post hooks through the system shell. Post runs under its own deadline even when the context is cancelled, so a quiesced server is released after an interrupted walk.

func (*Runner) RunPost

func (r *Runner) RunPost(ctx context.Context) error

RunPost runs the post hook, ignoring the context's cancellation.

func (*Runner) RunPre

func (r *Runner) RunPre(ctx context.Context) (string, error)

RunPre runs the pre hook and returns what it printed to stdout.

Jump to

Keyboard shortcuts

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