Documentation
¶
Overview ¶
Package clipboard provides cgo-free access to the system clipboard.
The API is intentionally tiny: read and write UTF-8 text, and images as PNG bytes. Each platform binds the clipboard the OS already provides — NSPasteboard on macOS, the Win32 clipboard on Windows, and X11/Wayland on Linux — with no cgo and no bundled native libraries.
old, _ := clipboard.ReadText()
clipboard.WriteText("hello")
Text is exchanged as UTF-8 Go strings; the backend handles any conversion the platform needs (UTF-16 on Windows, NSString on macOS).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupported = errors.New("clipboard: not supported on this platform")
ErrUnsupported is returned by operations on a platform that has no clipboard backend wired up yet.
Functions ¶
func ReadImage ¶ added in v0.1.13
ReadImage returns the clipboard's image as PNG bytes, converting from the platform's other image formats when needed. No image yields nil and a nil error. Implemented on macOS; elsewhere ErrUnsupported.
func ReadText ¶
ReadText returns the clipboard's current text content. An empty clipboard (or one holding only non-text data) yields an empty string and a nil error.
func WriteImage ¶ added in v0.1.13
WriteImage replaces the clipboard's content with a PNG image.
Types ¶
This section is empty.