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

local

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Overview

Package local runs the node's own `tailscale` CLI for read-only tools (spec §18).

Contract: absolute binary, fixed argv built by the tools, no shell, a built (not inherited) environment, working directory "/", stdin closed, capped output, the whole process group killed on timeout (on Windows, the CLI process itself), a bounded wait for output after exit, and a call-rate bucket.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UserHome

func UserHome() string

UserHome returns the home directory for the CLI environment.

Types

type Binary

type Binary struct {
	Path    string
	Variant Variant
}

Binary is a discovered tailscale CLI.

func Candidates

func Candidates(goos string) []Binary

Candidates lists the default search order for goos.

func Discover

func Discover(configured string, stat func(string) (fs.FileInfo, error)) (Binary, error)

Discover returns the configured binary, or the first candidate that exists.

type Result

type Result struct {
	Stdout   []byte
	Stderr   string
	Exit     int
	Duration time.Duration
	Warnings []string // e.g. CLI/daemon version skew reported on stderr
}

Result is the outcome of one CLI call.

type Runner

type Runner struct {
	Bin       Binary
	Socket    string // optional --socket
	Home      string
	MaxStdout int // default 4 MiB
	PerMinute int // default 30
	Now       func() time.Time
	// contains filtered or unexported fields
}

Runner executes the CLI.

func (*Runner) Env

func (r *Runner) Env() []string

Env is the complete environment given to the CLI. /usr/sbin is required: on macOS the open-source CLI locates the GUI daemon with tools found there. On Windows, os/exec also adds SYSTEMROOT, which Windows programs need.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, timeout time.Duration, args ...string) (Result, error)

Run executes the binary with args, the first of which is the subcommand. It returns *tkerr.Error values classified by the daemon states of spec §18.

type Variant

type Variant string

Variant names the installed flavour of Tailscale (spec §18.1).

const (
	VariantConfigured  Variant = "configured"
	VariantHomebrewOSS Variant = "macos-open-source-cli"
	VariantStandalone  Variant = "macos-standalone-launcher"
	VariantAppBundle   Variant = "macos-app-bundle"
	VariantLinux       Variant = "linux"
	VariantWindows     Variant = "windows"
)

Jump to

Keyboard shortcuts

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