πŸ“‹ cross-platform clipboard package that supports accessing text and image in Go (macOS/Linux/Windows/Android/iOS)

Overview

clipboard PkgGoDev clipboard

Cross platform (macOS/Linux/Windows/Android/iOS) clipboard package in Go

import "golang.design/x/clipboard"

Features

  • Cross platform supports: macOS, Linux (X11), Windows, iOS, and Android
  • Copy/paste UTF-8 text
  • Copy/paste PNG encoded images (Desktop-only)
  • Command gclip as a demo application
  • Mobile app gclip-gui as a demo application

API Usage

Package clipboard provides three major APIs for manipulating the clipboard: Read, Write, and Watch. The most common operations are Read and Write. To use them, you can:

// write/read text format data of the clipboard, and
// the byte buffer regarding the text are UTF8 encoded.
clipboard.Write(clipboard.FmtText, []byte("text data"))
clipboard.Read(clipboard.FmtText)

// write/read image format data of the clipboard, and
// the byte buffer regarding the image are PNG encoded.
clipboard.Write(clipboard.FmtImage, []byte("image data"))
clipboard.Read(clipboard.FmtImage)

Note that read/write regarding image format assumes that the bytes are PNG encoded since it serves the alpha blending purpose that might be used in other graphical software.

In addition, clipboard.Write returns a channel that can receive an empty struct as a signal, which indicates the corresponding write call to the clipboard is outdated, meaning the clipboard has been overwritten by others and the previously written data is lost. For instance:

changed := clipboard.Write(clipboard.FmtText, []byte("text data"))

select {
case <-changed:
      println(`"text data" is no longer available from clipboard.`)
}

You can ignore the returning channel if you don't need this type of notification. Furthermore, when you need more than just knowing whether clipboard data is changed, use the watcher API:

ch := clipboard.Watch(context.TODO(), clipboard.FmtText)
for data := range ch {
      // print out clipboard data whenever it is changed
      println(string(data))
}

Demos

  • A command line tool gclip for command line clipboard accesses, see document here.
  • A GUI application gclip-gui for functionality verifications on mobile systems, see a document here.

Command Usage

gclip command offers the ability to interact with the system clipboard from the shell. To install:

$ go install golang.design/x/clipboard/cmd/[email protected]
$ gclip
gclip is a command that provides clipboard interaction.

usage: gclip [-copy|-paste] [-f <file>]

options:
  -copy
        copy data to clipboard
  -f string
        source or destination to a given file path
  -paste
        paste data from clipboard

examples:
gclip -paste                    paste from clipboard and prints the content
gclip -paste -f x.txt           paste from clipboard and save as text to x.txt
gclip -paste -f x.png           paste from clipboard and save as image to x.png

cat x.txt | gclip -copy         copy content from x.txt to clipboard
gclip -copy -f x.txt            copy content from x.txt to clipboard
gclip -copy -f x.png            copy x.png as image data to clipboard

If -copy is used, the command will exit when the data is no longer available from the clipboard. You can always send the command to the background using a shell & operator, for example:

$ cat x.txt | gclip -copy &

Platform Specific Details

This package spent efforts to provide cross platform abstraction regarding accessing system clipboards, but here are a few details you might need to know.

Dependency

  • macOS: require Cgo, no dependency
  • Linux: require X11 dev package. For instance, install libx11-dev or xorg-dev or libX11-devel to access X window system.
  • Windows: no Cgo, no dependency
  • iOS/Android: collaborate with gomobile

Screenshot

In general, when you need test your implementation regarding images, There are system level shortcuts to put screenshot image into your system clipboard:

  • On macOS, use Ctrl+Shift+Cmd+4
  • On Linux/Ubuntu, use Ctrl+Shift+PrintScreen
  • On Windows, use Shift+Win+s

As described in the API documentation, the package supports read/write UTF8 encoded plain text or PNG encoded image data. Thus, the other types of data are not supported yet, i.e. undefined behavior.

Who is using this package?

The main purpose of building this package is to support the midgard project, which offers clipboard-based features like universal clipboard service that syncs clipboard content across multiple systems, allocating public accessible for clipboard content, etc.

To know more projects, check our wiki page.

License

MIT | Β© 2021 The golang.design Initiative Authors, written by Changkun Ou.

Comments
  • Image read may block on Windows 10

    Image read may block on Windows 10

    when copy text can get text content; but copy image, Read blocking

    package main
    
    import (
    	"fmt"
    	"golang.design/x/clipboard"
    )
    
    func main()  {
    
    	fmt.Println(clipboard.Read(clipboard.FmtImage))
    }
    
    invalid 
    opened by seth-shi 21
  • Using clipboard trough ssh

    Using clipboard trough ssh

    I have a TUI application, which could potencially run trough ssh. It's a rss reader with sixel images: https://sr.ht/~ghost08/photon There are keybindings to copy the rss item's link, or the item's image, for which I use the golang-design/clipboard library.

    But when I run it trough ssh it just panics this:

    panic: Failed to initialize the X11 display, and the clipboard package
    will not work properly. Install the following dependency may help:
    
    	apt install -y libx11-dev
    
    If the clipboard package is in an environment without a frame buffer,
    such as a cloud server, it may also be necessary to install xvfb:
    
    	apt install -y xvfb
    
    and initialize a virtual frame buffer:
    
    	Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
    	export DISPLAY=:99.0
    
    Then this package should be ready to use.
    
    
    goroutine 1 [running]:
    golang.design/x/clipboard.init.0()
    	golang.design/x/[email protected]/clipboard_linux.go:65 +0x4b
    

    Is there a way to ignore the missing display and don't panic? I know that trough ssh clipboard will not work, but that's ok.

    enhancement 
    opened by microo8 9
  • Warn and panic when CGO_ENABLED is set to 0

    Warn and panic when CGO_ENABLED is set to 0

    I'm not sure which library caused the problem. I wrote a demo to verify, it said

       β¨― release failed after 0.53s error=failed to build for darwin_arm64: exit status 2: # golang.design/x/clipboard
    ../../../go/pkg/mod/golang.design/x/[email protected]/clipboard.go:90:14: undefined: read
    ../../../go/pkg/mod/golang.design/x/[email protected]/clipboard.go:110:18: undefined: write
    ../../../go/pkg/mod/golang.design/x/[email protected]/clipboard.go:125:9: undefined: watch
    

    demo

    Any ideas?

    enhancement 
    opened by Dawnnnnnn 5
  • Doesn't work with some target application on Windows 10

    Doesn't work with some target application on Windows 10

    Hi, congratulations for your library, it is very useful and especially it's written in pure Go. I have no problems at all while running on Linux, but when it comes to Windows problems magically appear (as always). Basically, I am putting an image received from the network into the clipboard, but on Windows I get a broken clipboard, which makes impossible to copy-paste anything until I stop the application. Using the clipboard history on Windows 10 I can partially see the image sent, but anyway all is gone. The image I am sending is PNG encoded at the source, then send to my application which takes the image bytes received in a multipart HTTP form and puts it into the clipboard.

    Thanks for help.

    UPDATE: I tried the demo tool gclip and it is able to save to a file the clipboard content, while ctrl+v (or gui equivalent) simply doesn't work as I said before. Once the file is saved, the clipboard begins to work again and I'm able to paste again.

    bug NeedsInvestigation 
    opened by DarkFighterLuke 5
  • Add Init()

    Add Init()

    If you are using Linux without X11 enabled, an error will occur at the time of import. Add Test() methods to check if the clipboard is accessible for conditional branching.

    Fixes #19

    opened by hrntknr 4
  • linux: dynamically load libX11

    linux: dynamically load libX11

    Removing linking of libX11 and replacing it with dlopen to call the functions dynamically. For the future wayland support, the library will not require the libX11 library to be installed on the running system. For compiling it we need it, because of the huge and complicated type definitions, but the compiled binary will run also on a system without libX11.

    Maybe in the future we can eliminate also the X11/Xlib.h and X11/Xatom.h. The only thing that really needs to be declared is the XEvent and it's attributes, other things can be a void pointer or some c primitives.

    opened by microo8 3
  • Exit directly after copying

    Exit directly after copying

    if :

    clipboard.Write(clipboard.FmtText, []byte("hello world"))
    exit()
    

    or

    clipboard.Write(clipboard.FmtImage, content)
    exit()
    

    there will be nothing in clipboard else:

    <-clipboard.Write(clipboard.FmtText, []byte(imagePath))
    

    clipboard is ok,but program is blocked untill something new is copied into clipboad .


    ubuntu20.04

    invalid 
    opened by TaceyWong 3
  • Backward compatibility for Go 1.16

    Backward compatibility for Go 1.16

    Newbie here. When I ran commands below:

    $ go version
    go version go1.16.8 linux/amd64
    $ go mod init main
    $ touch main.go
    $ go get -u golang.design/x/clipboard                                                                                                                                     ✘ 1 
    //go:build comment without // +build comment
    $ go run main                                                                                                                                                             ✘ 1 
    main.go:4:8: no required module provides package golang.design/x/clipboard; to add it:
            go get golang.design/x/clipboard
    $ go get golang.design/x/clipboard                                                                                                                                        ✘ 1 
    //go:build comment without // +build comment
    

    I got //go:build comment without // +build comment, but the go.mod file never changed. So how could I install golang-design/clipboard?

    main.go

    package main
    
    import "fmt"
    import "golang.design/x/clipboard"
    
    func main(){
    	fmt.Println("hi")
    }
    
    enhancement 
    opened by FrankFang 3
  • Release v0.4.5 not yet pushed to https://pkg.go.dev/golang.design/x/clipboard

    Release v0.4.5 not yet pushed to https://pkg.go.dev/golang.design/x/clipboard

    Thanks for this very helpful package. I noticed a bug in Windows using your package. It seems that you've already fixed it here: #3 While the new release is pushed on github it is not yet available for "go get" because https://pkg.go.dev/golang.design/x/clipboard still references to v0.4.4 as "LATEST". I'd appreciate, if you could fix this.

    bug 
    opened by mc51 3
  • ld: error: duplicate symbol: when using with Fyne Android

    ld: error: duplicate symbol: when using with Fyne Android

    I tried to remove the clipboard it's working fine.

    logs

    $ fyne-cross android
    [i] Target: android/multiple
    [i] Cleaning target directories...
    [βœ“] "dist" dir cleaned: C:\Users\ntsd\Desktop\git\ntsd\cross-clipboard\fyne-cross\dist\android
    [βœ“] "temp" dir cleaned: C:\Users\ntsd\Desktop\git\ntsd\cross-clipboard\fyne-cross\tmp\android
    [βœ“] "bin" dir cleaned: C:\Users\ntsd\Desktop\git\ntsd\cross-clipboard\fyne-cross\bin\android
    [i] Checking for go.mod: C:\Users\ntsd\Desktop\git\ntsd\cross-clipboard\go.mod
    [βœ“] go.mod found
    [i] Packaging app...
    go build -buildmode=c-shared -o /tmp/gomobile-work-1926614866/lib/armeabi-v7a/libcross-clipboard.so github.com/ntsd/cross-clipboard failed: exit status 2
    # fyne.io/fyne/v2/internal/driver/mobile
    android.c:50:9: warning: returning 'const char *' from a function with result type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
    android.c:67:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]     
    android.c:71:55: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]     
    android.c:122:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]    
    android.c:125:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]    
    android.c:181:50: warning: passing 'char *' to parameter of type 'jbyte *' (aka 'signed char *') converts between pointers to integer types with different sign [-Wpointer-sign]   
    android.c:191:48: warning: passing 'char *' to parameter of type 'const jbyte *' (aka 'const signed char *') converts between pointers to integer types with different sign [-Wpointer-sign]
    # fyne.io/fyne/v2/app
    app_mobile_and.c:46:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]
    app_mobile_and.c:49:48: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]
    app_mobile_and.c:85:30: warning: incompatible integer to pointer conversion passing 'uintptr_t' (aka 'unsigned int') to parameter of type 'jobject' (aka 'void *') [-Wint-conversion]
    app_mobile_and.c:98:33: warning: incompatible pointer to integer conversion passing 'JNIEnv *' (aka 'const struct JNINativeInterface **') to parameter of type 'uintptr_t' (aka 'unsigned int') [-Wint-conversion]
    app_mobile_and.c:42:36: note: passing argument to parameter 'jni_env' here
    # github.com/ntsd/cross-clipboard
    /usr/local/go/pkg/tool/linux_amd64/link: running /usr/local/android_sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi16-clang failed: exit status 1
    ld: error: duplicate symbol: callMain
    >>> defined at _cgo_export.c:44
    >>>            /tmp/go-link-655786190/000020.o:(callMain)
    >>> defined at _cgo_export.c:44
    >>>            /tmp/go-link-655786190/000039.o:(.text+0x50)
    
    ld: error: duplicate symbol: onConfigurationChanged
    >>> defined at _cgo_export.c:334
    >>>            /tmp/go-link-655786190/000020.o:(onConfigurationChanged)
    >>> defined at _cgo_export.c:317
    >>>            /tmp/go-link-655786190/000039.o:(.text+0x4D4)
    
    ld: error: duplicate symbol: onContentRectChanged
    >>> defined at _cgo_export.c:298
    >>>            /tmp/go-link-655786190/000020.o:(onContentRectChanged)
    >>> defined at _cgo_export.c:298
    >>>            /tmp/go-link-655786190/000039.o:(.text+0x484)
    
    ld: error: duplicate symbol: onCreate
    >>> defined at _cgo_export.c:150
    >>>            /tmp/go-link-655786190/000020.o:(onCreate)
    >>> defined at _cgo_export.c:150
    >>>            /tmp/go-link-655786190/000039.o:(.text+0x214)
    
    ld: error: duplicate symbol: onDestroy
    >>> defined at _cgo_export.c:167
    >>>            /tmp/go-link-655786190/000020.o:(onDestroy)
    >>> defined at _cgo_export.c:167
    >>>            /tmp/go-link-655786190/000039.o:(.text+0x25C)
    
    ld: error: duplicate symbol: onInputQueueCreated
    >>> defined at _cgo_export.c:260
    >>>            /tmp/go-link-655786190/000020.o:(onInputQueueCreated)
    >>> defined at _cgo_export.c:260
    >>>            /tmp/go-link-655786190/000039.o:(.text+0x3E4)
    
    ld: error: duplicate symbol: onInputQueueDestroyed
    >>> defined at _cgo_export.c:279
    >>>            /tmp/go-link-655786190/000020.o:(onInputQueueDestroyed)
    >>> defined at _cgo_export.c:279
    >>>            /tmp/go-link-655786190/000039.o:(.text+0x434)
    
    ld: error: duplicate symbol: onLowMemory
    >>> defined at _cgo_export.c:351
    >>>            /tmp/go-link-655786190/000020.o:(onLowMemory)
    >>> defined at _cgo_export.c:334
    >>>            /tmp/go-link-655786190/000039.o:(.text+0x51C)
    
    ld: error: duplicate symbol: onNativeWindowCreated
    >>> defined at _cgo_export.c:203
    >>>            /tmp/go-link-655786190/000020.o:(onNativeWindowCreated)
    >>> defined at _cgo_export.c:203
    >>>            /tmp/go-link-655786190/000039.o:(.text+0x2F4)
    
    ld: error: duplicate symbol: onNativeWindowDestroyed
    >>> defined at _cgo_export.c:241
    >>>            /tmp/go-link-655786190/000020.o:(onNativeWindowDestroyed)
    >>> defined at _cgo_export.c:241
    >>>            /tmp/go-link-655786190/000039.o:(.text+0x394)
    
    ld: error: duplicate symbol: onNativeWindowRedrawNeeded
    >>> defined at _cgo_export.c:222
    >>>            /tmp/go-link-655786190/000020.o:(onNativeWindowRedrawNeeded)
    >>> defined at _cgo_export.c:222
    >>>            /tmp/go-link-655786190/000039.o:(.text+0x344)
    
    ld: error: duplicate symbol: onPause
    >>> defined at _cgo_export.c:116
    >>>            /tmp/go-link-655786190/000020.o:(onPause)
    >>> defined at _cgo_export.c:116
    >>>            /tmp/go-link-655786190/000039.o:(.text+0x184)
    
    ld: error: duplicate symbol: onResume
    >>> defined at _cgo_export.c:78
    >>>            /tmp/go-link-655786190/000020.o:(onResume)
    >>> defined at _cgo_export.c:78
    >>>            /tmp/go-link-655786190/000039.o:(.text+0xE0)
    
    ld: error: duplicate symbol: onSaveInstanceState
    >>> defined at _cgo_export.c:95
    >>>            /tmp/go-link-655786190/000020.o:(onSaveInstanceState)
    >>> defined at _cgo_export.c:95
    >>>            /tmp/go-link-655786190/000039.o:(.text+0x128)
    
    ld: error: duplicate symbol: onStart
    >>> defined at _cgo_export.c:61
    >>>            /tmp/go-link-655786190/000020.o:(onStart)
    >>> defined at _cgo_export.c:61
    >>>            /tmp/go-link-655786190/000039.o:(.text+0x98)
    
    ld: error: duplicate symbol: onStop
    >>> defined at _cgo_export.c:133
    >>>            /tmp/go-link-655786190/000020.o:(onStop)
    >>> defined at _cgo_export.c:133
    >>>            /tmp/go-link-655786190/000039.o:(.text+0x1CC)
    
    ld: error: duplicate symbol: onWindowFocusChanged
    >>> defined at _cgo_export.c:184
    >>>            /tmp/go-link-655786190/000020.o:(onWindowFocusChanged)
    >>> defined at _cgo_export.c:184
    >>>            /tmp/go-link-655786190/000039.o:(.text+0x2A4)
    
    ld: error: duplicate symbol: setCurrentContext
    >>> defined at _cgo_export.c:25
    >>>            /tmp/go-link-655786190/000020.o:(setCurrentContext)
    >>> defined at _cgo_export.c:25
    >>>            /tmp/go-link-655786190/000039.o:(.text+0x0)
    
    ld: error: duplicate symbol: ANativeActivity_onCreate
    >>> defined at android.c:76
    >>>            /tmp/go-link-655786190/000023.o:(ANativeActivity_onCreate)
    >>> defined at android.c:72
    >>>            /tmp/go-link-655786190/000041.o:(.text+0x40)
    
    ld: error: duplicate symbol: JNI_OnLoad
    >>> defined at android.c:57
    >>>            /tmp/go-link-655786190/000023.o:(JNI_OnLoad)
    >>> defined at android.c:53
    >>>            /tmp/go-link-655786190/000041.o:(.text+0x0)
    
    ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    
    
    [βœ—] could not package the Fyne app: could not package the Fyne app: exit status 1
    

    Go version: 1.18 Clipboard version: 0.6.2 Fyne version: 2.1.4 NDK version: 21.4.7075529, 23.1.7779620

    invalid WaitingForInfo 
    opened by ntsd 2
  • Can add some function let us know the bytes is image or text

    Can add some function let us know the bytes is image or text

    Hi, @changkun Thank you to create the wonderful framework. Can you provide a way for us to read the clipboard content as a stream of characters or images?

    Like this

    func IsText() bool
    func IsImage() bool
    
    opened by 52funny 2
  • Segmentation violation using the gclip tool on Fedora

    Segmentation violation using the gclip tool on Fedora

    I have been using clipboard to build a small personal application as a replacement for xclip. The first time I built and tested the application, it threw this error:

    fatal error: unexpected signal during runtime execution
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x0]
    
    runtime stack:
    runtime.throw({0x4bc05d?, 0x1?})
            /usr/local/go/src/runtime/panic.go:992 +0x71
    runtime.sigpanic()
            /usr/local/go/src/runtime/signal_unix.go:802 +0x3a9
    
    goroutine 1 [syscall, locked to thread]:
    runtime.cgocall(0x4996f0, 0xc00006fde8)
            /usr/local/go/src/runtime/cgocall.go:157 +0x5c fp=0xc00006fdc0 sp=0xc00006fd88 pc=0x40521c
    golang.design/x/clipboard._Cfunc_clipboard_test()
            _cgo_gotypes.go:93 +0x48 fp=0xc00006fde8 sp=0xc00006fdc0 pc=0x498028
    golang.design/x/clipboard.initialize()
            /home/$USER/.go/pkg/mod/golang.design/x/[email protected]/clipboard_linux.go:60 +0x1d fp=0xc00006fe30 sp=0xc00006fde8 pc=0x49829d
    golang.design/x/clipboard.Init(...)
            /home/$USER/.go/pkg/mod/golang.design/x/[email protected]/clipboard.go:102
    main.init.0()
            /home/$USER/.go/pkg/mod/golang.design/x/[email protected]/cmd/gclip/main.go:47 +0x1a fp=0xc00006fe50 sp=0xc00006fe30 pc=0x49903a
    runtime.doInit(0x546a00)
            /usr/local/go/src/runtime/proc.go:6222 +0x126 fp=0xc00006ff80 sp=0xc00006fe50 pc=0x4429e6
    runtime.main()
            /usr/local/go/src/runtime/proc.go:233 +0x1d3 fp=0xc00006ffe0 sp=0xc00006ff80 pc=0x435a93
    runtime.goexit()
            /usr/local/go/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc00006ffe8 sp=0xc00006ffe0 pc=0x45ebc1
    

    I thought it was an issue with my code, but the gclip reference tool throws the same error, so I must assume that the issue lies with the clipboard library. My /etc/os-release file (unsure if this helps):

    VERSION="35 (KDE Plasma)"
    ID=fedora
    VERSION_ID=35
    VERSION_CODENAME=""
    PLATFORM_ID="platform:f35"
    PRETTY_NAME="Fedora Linux 35 (KDE Plasma)"
    ANSI_COLOR="0;38;2;60;110;180"
    LOGO=fedora-logo-icon
    CPE_NAME="cpe:/o:fedoraproject:fedora:35"
    HOME_URL="https://fedoraproject.org/"
    DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f35/system-administrators-guide/"
    SUPPORT_URL="https://ask.fedoraproject.org/"
    BUG_REPORT_URL="https://bugzilla.redhat.com/"
    REDHAT_BUGZILLA_PRODUCT="Fedora"
    REDHAT_BUGZILLA_PRODUCT_VERSION=35
    REDHAT_SUPPORT_PRODUCT="Fedora"
    REDHAT_SUPPORT_PRODUCT_VERSION=35
    PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
    VARIANT="KDE Plasma"
    VARIANT_ID=kde```
    help wanted NeedsInvestigation 
    opened by CmdrNorthpaw 5
  • Remove Linux Cgo requirement

    Remove Linux Cgo requirement

    Did you consider using https://github.com/BurntSushi/xgb which is Cgo free/native binding to XCB? I am not sure though, but it should be possible to rewrite with XCB instead of Xlib so Linux implementation can be Cgo free.

    enhancement NeedsInvestigation platform-specific 
    opened by gen2brain 1
  • Limit number of read requests by other applications

    Limit number of read requests by other applications

    Hey @changkun,

    Thank you for your great work. I am wondering how hard it would be to implement the equivalent of the -l, -loops switch of xclip (X11Β tool on Linux) in your package. The goal would be to allow only a limited number of Read operations on the clipboard before the content gets flushed. I am currently relying on piping to xclip to do that but IΒ think it is not very clean and I'd like to opt for a full C/Go approach.

    Cheers,

    enhancement platform-specific 
    opened by qjerome 8
  • Allow Custom Format

    Allow Custom Format

    Currently, we only support UTF-8 text and PNG-encoded image data. However, there are much more formats than that.

    Let's support registering custom format and handlers so that this package can help any other unregistered format. API design could be:

    package clipboard
    
    type Format int
    
    // Add this.
    func Register[T any](format clipboard.Format, read func([]byte) (T, error), write func() []byte) error { ... }
    
    func Read(format clipboard.Format) []byte
    func Write(format clipboard.Format, data []byte)
    func Watch(format clipboard.Format) <-chan struct{}
    
    enhancement NeedsInvestigation 
    opened by changkun 0
Releases(v0.6.2)
Owner
The golang.design Initiative
Hopefully everything about Go!
The golang.design Initiative
Generates random text based on trigrams generated from input text

Trigrams Generates random text based on trigrams generated from input text Contents Building Running Using Implementation notes NGram size Maximum wor

null 0 Feb 9, 2022
Cross-platform Bluetooth API for Go and TinyGo.

Go Bluetooth is a cross-platform package for using Bluetooth Low Energy hardware from the Go programming language.

TinyGo 436 Sep 15, 2022
Cross platform locale detection for Golang

go-locale go-locale is a Golang lib for cross platform locale detection. OS Support Support all OS that Golang supported, except android: aix: IBM AIX

Xuanwo 86 Aug 20, 2022
Go library to help build a macOS device attestation service.

About macos-device-attestation is a library to help build a macOS device attestation service. An on-device client can use this library to attest to a

Kory Prince 0 Nov 17, 2021
Package ethtool allows control of the Linux ethtool generic netlink interface.

ethtool Package ethtool allows control of the Linux ethtool generic netlink interface.

Matt Layher 47 Sep 7, 2022
Grabs the IP adress, discord tokens and Windows NT Users in the machine. Only for educational purpuses!!

go-malware Grabs the IP adress, discord tokens and Windows NT Users in the machine. Only for educational purpuses!! Edit the main file and put your we

ant0n 3 Apr 13, 2022
Scalable golang ratelimiter using the sliding window algorithm. Currently supports only Redis.

go-ratelimiter Scalable golang ratelimiter using the sliding window algorithm. Currently supports only Redis. Example usage client := redis.NewClient

null 0 Oct 19, 2021
Goterators - A util library that Supports aggregate & transforms functions Go. Such as filter, map, reduce, find, exist

Goterators Goterators is util library that Supports aggregate & transforms functions Go, including: for-each find exist reduce filter map API and func

Thuc Le 90 Sep 22, 2022
Flock is a project which provides a Go solution for system level file locks for all platforms Golang supports.

Flock is a project which provides a Go solution for system level file locks for all platforms Golang supports.

Ken Sipe 0 Feb 8, 2022
Procswap is a simple application that allows you to prioritize processes on a Windows machine.

Procswap is a simple application that allows you to prioritize processes on a Windows machine.

Billy 19 Mar 8, 2022
get windows system call number dynamically, it doesn't need the system call table.

GetSyscallID get windows system call number dynamically, it doesn't need the system call table. Try download go get github.com/akkuman/getsyscallid/cm

null 7 Jun 1, 2022
Go library that provides fuzzy string matching optimized for filenames and code symbols in the style of Sublime Text, VSCode, IntelliJ IDEA et al.

Go library that provides fuzzy string matching optimized for filenames and code symbols in the style of Sublime Text, VSCode, IntelliJ IDEA et al. This library is external dependency-free. It only depends on the Go standard library.

Sahil Muthoo 1.2k Sep 22, 2022
tail a text file and trigger an action if a new line occurs [wip]

Tailpipe Synopsis Config Help Synopsis Tail a file and trigger an action if a new line occurs. Currently only mailing the new line somewhere is suppor

Olaf Michaelis 0 Dec 23, 2021
Daypaper sets your GNOME wallpaper based on the time of day from a random and relevant Unsplash image.

Daypaper Daypaper sets your GNOME wallpaper based on the time of day from a random and relevant Unsplash image. Installation You will need an Access T

Matteo Guglielmetti 15 May 23, 2022
Perforator is a tool for recording performance metrics over subregions of a program using the Linux "perf" interface.

Perforator Perforator is a tool for recording performance metrics over subregions of a program (e.g., functions) using the Linux "perf" interface.

Zachary Yedidia 33 May 5, 2022
Automatically set GOMAXPROCS to match Linux container CPU quota.

automaxprocs Automatically set GOMAXPROCS to match Linux container CPU quota. Installation go get -u go.uber.org/automaxprocs Quick Start import _ "go

Uber Go 2.2k Sep 25, 2022
A Go library for the Linux Landlock sandboxing feature

Go Landlock library The Go Landlock library restricts the current processes' ability to use files, using Linux 5.13's Landlock feature. (Package docum

Landlock LSM 74 Sep 16, 2022
A fully Go userland with Linux bootloaders! u-root can create a one-binary root file system (initramfs) containing a busybox-like set of tools written in Go.

u-root Description u-root embodies four different projects. Go versions of many standard Linux tools, such as ls, cp, or shutdown. See cmds/core for m

null 2k Sep 23, 2022
Execute a binary from memory, without touching the disk. Linux only.

Memit Execute a binary from memory, without touching the disk. Linux only. Available as both a Go module and a binary. Using the Go module The Command

Liam Galvin 235 Sep 12, 2022