A cross-platform Go library for clipboard operations.
Supports Linux, macOS, Windows, and WSL environments.
- Copy text to the native clipboard on all major platforms
- Special support for copying from WSL to Windows clipboard
- Simple, thread-safe API
- Empty strings are rejected automatically
Platform-specific implementations use Go build tags, so only the required clipboard backend is compiled into the final binary.
import "github.com/rshayer95/go-clipboard/clipboard"
cb, err := clipboard.New()
if err != nil {
log.Fatal(err)
}
cb.Copy("Hello, world!")
cb.CopyToHost("Hello from WSL!")