summaryrefslogtreecommitdiff
path: root/internal/util/clipboard.go
blob: 4aaf828edd6cb7285e064b264873e4699c93c799 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package util

import (
	"log/slog"

	"golang.design/x/clipboard"
)

// Copies any object that has the Stringer interface to the clipboard
func Copy(str string) {
	// Initialize the clipboard
	if err := clipboard.Init(); err != nil {
		slog.Error("failed to initialize clipboard", "error", err)
		return
	}

	clipboard.Write(clipboard.FmtText, []byte(str))
}