clipboard

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

This directory based on clipboard.

Build Status GoDoc

Clipboard for Go

Provide copying and pasting to the Clipboard for Go.

Build:

$ go get github.com/atotto/clipboard

Platforms:

  • OSX
  • Windows 7 (probably work on other Windows)
  • Linux, Unix (requires 'xclip' or 'xsel' command to be installed)

Document:

Notes:

  • Text string only
  • UTF-8 text encoding only (no conversion)

TODO:

  • Clipboard watcher(?)

Commands:

paste shell command:

$ go get github.com/atotto/clipboard/cmd/gopaste
$ # example:
$ gopaste > document.txt

copy shell command:

$ go get github.com/atotto/clipboard/cmd/gocopy
$ # example:
$ cat document.txt | gocopy

Documentation

Overview

Package clipboard read/write on clipboard

Index

Constants

This section is empty.

Variables

View Source
var (
	// Primary chooses primary mode for the legacy ReadAll and WriteAll APIs.
	// Deprecated: use ReadAllContext or WriteAllContext with SelectionPrimary.
	Primary bool
)
View Source
var Unsupported bool

Unsupported might be set true during clipboard init, to help callers decide whether or not to offer clipboard options.

Functions

func ReadAll

func ReadAll() (string, error)

ReadAll read string from clipboard

func ReadAllContext

func ReadAllContext(ctx context.Context, selection ...Selection) (string, error)

ReadAllContext reads the requested selection and allows cancellation.

func WriteAll

func WriteAll(text string) error

WriteAll write string to clipboard

func WriteAllContext

func WriteAllContext(ctx context.Context, text string, selection ...Selection) error

WriteAllContext writes the requested selection and allows cancellation.

Types

type Selection

type Selection uint8

Selection identifies the clipboard selection to access.

const (
	SelectionClipboard Selection = iota
	SelectionPrimary
)

Directories

Path Synopsis
cmd
gocopy command
gopaste command

Jump to

Keyboard shortcuts

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