From ec84a4f1dca36a18c93b9f96e262cca34853c086 Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Sun, 24 Nov 2024 01:07:05 -0500 Subject: Implement clipboard --- internal/util/clipboard.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 internal/util/clipboard.go (limited to 'internal/util') diff --git a/internal/util/clipboard.go b/internal/util/clipboard.go new file mode 100644 index 0000000..4aaf828 --- /dev/null +++ b/internal/util/clipboard.go @@ -0,0 +1,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)) +} -- cgit v1.2.3