Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/tiagomelo/go-clipboard

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/tiagomelo/go-clipboard

  • v0.1.1
  • Source
  • Go
  • Socket score

Version published
Created
Source

go-clipboard

logo

A cross-platform clipboard utility for Go.

It offers abilities for copying and pasting plain text.

installation

go get github.com/tiagomelo/go-clipboard

documentation

https://pkg.go.dev/github.com/tiagomelo/go-clipboard

platforms

OSSupported copy toolsSupported paste tools
Darwinpbcopypbpaste
Windowsclip.exepowershell
Linux/FreeBSD/NetBSD/OpenBSD/DragonflyX11: xsel, xclip
Wayland: wl-copy
X11: xsel, xclip
Wayland: wl-paste
SolarisX11: xsel, xclipX11: xsel, xclip
Android (via Termux)termux-clipboard-settermux-clipboard-get

examples

copy

examples/copy/copy.go

package main

import (
	"fmt"
	"os"

	clipboard "github.com/tiagomelo/go-clipboard/clipboard"
)

func main() {
	text := "some text"
	c := clipboard.New()
	if err := c.CopyText(text); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	fmt.Printf("text \"%s\" was copied into clipboard. Paste it elsewhere.\n", text)
}

paste

examples/paste/paste.go

package main

import (
	"fmt"
	"os"

	clipboard "github.com/tiagomelo/go-clipboard/clipboard"
)

func main() {
	c := clipboard.New()
	text, err := c.PasteText()
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	fmt.Printf("text from clipboard: %v\n", text)
}

unit tests

*nix

make test

Windows

run-tasks.bat test

FAQs

Package last updated on 21 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc