Couldn't find a go clipboard package which is both multi-platform and doesn't require additional installations. So this package is a combination of work of wonderful and talented people who created the packages mentioned in credits.
- OSX
- Windows
- Linux, Unix
go get github.com/f1bonacc1/glippy
package main
import (
"fmt"
"github.com/f1bonacc1/glippy"
)
func main(){
// set clipboard text
glippy.Set("Hello, Glippy")
// get clipboard text
text, err := glippy.Get()
if err != nil{
panic(err)
}
fmt.Print(text) // Output: "Hello, Glippy"
}
package main
import (
"context"
"fmt"
"github.com/f1bonacc1/glippy"
)
func main(){
// create clipboard watch channel
ch := glippy.Watch(context.Background())
for data := range ch {
fmt.Println(data)
}
}
https://github.com/atotto/clipboard