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

clipboard

package
v1.2.20 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package clipboard writes text to the system clipboard by shelling out to the platform's clipboard utility (US-009, #125). It deliberately avoids any cgo or third-party dependency: it probes for the standard command-line tools (pbcopy on macOS, wl-copy / xclip / xsel on Linux) and pipes text to the first one found. When no utility is available it reports ErrUnavailable so the caller can degrade gracefully (e.g. print the text instead).

Index

Constants

This section is empty.

Variables

View Source
var ErrUnavailable = errors.New("clipboard: no clipboard utility available")

ErrUnavailable is returned by Copy when no supported clipboard utility is found on the host, so the caller can fall back to printing the content.

Functions

func Available

func Available() bool

Available reports whether a clipboard utility is present, without writing anything. Useful for a caller that wants to phrase its output differently when it knows the copy will fail.

func Copy

func Copy(text string) error

Copy writes text to the system clipboard using the first available platform utility. It returns ErrUnavailable if none is found (so callers can fall back to printing), or the underlying exec error if a utility was found but failed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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