rsynccmd

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: BSD-3-Clause Imports: 4 Imported by: 1

Documentation

Overview

Package rsynccmd provides a command-like interface to gokrazy/rsync, which contains a native Go rsync implementation that supports sending and receiving files as client or server, compatible with the original tridge rsync (from the samba project) or openrsync (used on OpenBSD and macOS 15+).

This interface allows you to replace calls to an external rsync program, like:

rsync -a rsync://share01/dataset /tmp/dataset

…with calls into Go code running in the same process (no dependency on an external rsync program!):

cmd := rsynccmd.Command("rsync", "-a", "rsync://share01/dataset", "/tmp/dataset")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if _, err := cmd.Run(context.Background()); err != nil {
  return fmt.Errorf("%v: %v", cmd.Args, err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd struct {
	Args   []string
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

Cmd represents an rsync invocation being prepared or run.

func Command

func Command(name string, arg ...string) *Cmd

Command returns the Cmd struct to execute rsync with the given arguments.

The name parameter is ignored and only specified for symmetry with os/exec.Command.

func (*Cmd) Run

func (c *Cmd) Run(ctx context.Context) (*Result, error)

Run starts the specified rsync invocation.

type Result

type Result struct {
	Stats *rsyncstats.TransferStats
}

Result contains information about the transfer.

Jump to

Keyboard shortcuts

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