diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2024-11-24 01:07:05 -0500 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2024-11-24 01:07:05 -0500 |
commit | ec84a4f1dca36a18c93b9f96e262cca34853c086 (patch) | |
tree | fbc4e9f13736c387df71683c8c2a69890337c4c7 /internal/util/clipboard.go | |
parent | 7005459db8824695ded8aa755f6c7bb89e123fa0 (diff) |
Implement clipboard
Diffstat (limited to 'internal/util/clipboard.go')
-rw-r--r-- | internal/util/clipboard.go | 18 |
1 files changed, 18 insertions, 0 deletions
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)) +} |