From d92c9c601e1ef8c183562c94141db493de50921f Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Sun, 24 Nov 2024 01:10:15 -0500 Subject: Remove useless code and implement clipboard functionality (#1) * Remove dead code * Implement clipboard * Improve Stringer color interfaces --- internal/util/clipboard.go | 18 ++++++++++++++++++ internal/util/util.go | 9 --------- 2 files changed, 18 insertions(+), 9 deletions(-) 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)) +} diff --git a/internal/util/util.go b/internal/util/util.go index 9fea40c..e5b7273 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -1,12 +1,3 @@ package util const ErrKey = "error_message" - -func HexMap() [16]byte { - return [16]byte{ - '0', '1', '2', '3', - '4', '5', '6', '7', - '8', '9', 'a', 'b', - 'c', 'd', 'e', 'f', - } -} -- cgit v1.2.3