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

github.com/steven-xie/glip

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/steven-xie/glip

  • v1.2.1
  • Source
  • Go
  • Socket score

Version published
Created
Source

glip

A clipboard interface for Go, compatible with Windows, Mac OS X, and Linux.

Godoc: reference Go Report Card Travis: build Appveryor: build Codecov: coverage Github Release

Usage

Install glip like you would any other Go package:

go get github.com/stevenxie/glip

Since a glip.Board (a clipboard interface) includes io.Writer, io.Reader, io.WriterTo, and io.ReaderFrom, it can be used just about anywhere:

import (
  "fmt"
  "github.com/stevenxie/glip"
)

func main() {
  // Save "snip snip" into the system clipboard.
  glip.WriteString("snip snip")
  // And we're done!

  // Read clipboard contents into a string (ignoring the error).
  out, _ := glip.ReadString()
  fmt.Println(out)
  // Output: snip snip
}

Advanced Usage:

glip provides API-wrapping structs specific to each clipboard-accessing program; each struct implements the Board interface.

If you know which specific program you would like to use, you can create a new instance of the associated wrapper struct (i.e. PShellBoard, Clip, DarwinBoard, Xclip, or Xsel), and set program-specific flags / options using the wrapper struct.


Compatibility

Windows:

glip uses the the PowerShell Get-Clipboard and Set-Clipboard cmdlets to read and write to the Windows clipboard.

If PowerShell is not available, the clip command is used to write to the Windows clipboard.

macOS:

glip uses pbcopy and pbpaste commands on macOS.

Linux:

glip requires the installation of either xclip or xsel to function on Linux (since there's no built-in clipboard interface). glip will choose whichever program is available, with a preference for xsel if both are avaiklable.

Known Issues

glip sometimes seems to fail arbitrarily on x86 Windows, and I'm not sure why. It seems like the PowerShell clipboard modules are not very reliable?

If anybody can accurately diagnose the situation on a Windows machine, I'd be very grateful 🙂.


glipboard

For an example of an application that uses glip, check out glipboard (located at /cmd/glipboard/).

glipboard was developed to both showcase how glip can be used in a real application, as well as to be a universal clipboard interface that external programs can call in order to write to a system clipboard, if the underlying commands are available.

FAQs

Package last updated on 29 Nov 2018

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