Go语言学习: clipboard/剪贴板/pbcopy/copy 包

读写系统剪贴板的包 clipboard
更新于: 2024-10-31 23:43:13

安装

go get golang.design/x/clipboard

main.go

  • Write
  • Read
package main

import (
	"fmt"

	"golang.design/x/clipboard"
)

func main() {
	clipboard.Write(clipboard.FmtText, []byte("text data123123xyz"))
	res := clipboard.Read(clipboard.FmtText)
	fmt.Println(string(res))
}