Fix build on many platforms

This commit is contained in:
2026-02-13 19:13:06 -05:00
parent 3fd2b13712
commit 20d8e141eb
4 changed files with 13 additions and 13 deletions
+4 -4
View File
@@ -9,10 +9,10 @@ import (
"github.com/rwinkhart/go-boilerplate/back" "github.com/rwinkhart/go-boilerplate/back"
) )
// CopyString copies a string to the clipboard. // CopyBytes copies a byte slice to the clipboard.
func CopyString(clearClipboardAutomatically bool, copySubject string) error { func CopyBytes(clearClipboardAutomatically bool, copySubject []byte) error {
cmd := exec.Command("pbcopy") cmd := exec.Command("pbcopy")
_ = back.WriteToStdin(cmd, copySubject) _ = back.WriteToStdinAndZeroizeInput(cmd, copySubject)
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
return errors.New("unable to copy to clipboard: " + err.Error()) return errors.New("unable to copy to clipboard: " + err.Error())
} }
@@ -25,6 +25,6 @@ func CopyString(clearClipboardAutomatically bool, copySubject string) error {
// getClipCommands returns the commands for pasting and clearing the clipboard contents. // getClipCommands returns the commands for pasting and clearing the clipboard contents.
func getClipCommands() (*exec.Cmd, *exec.Cmd, error) { func getClipCommands() (*exec.Cmd, *exec.Cmd, error) {
cmdClear := exec.Command("pbcopy") cmdClear := exec.Command("pbcopy")
_ = back.WriteToStdin(cmdClear, "") _ = back.WriteToStdinAndZeroizeInput(cmdClear, nil)
return exec.Command("pbpaste"), cmdClear, nil return exec.Command("pbpaste"), cmdClear, nil
} }
+4 -4
View File
@@ -9,10 +9,10 @@ import (
"github.com/rwinkhart/go-boilerplate/back" "github.com/rwinkhart/go-boilerplate/back"
) )
// CopyString copies a string to the clipboard. // CopyBytes copies a byte slice to the clipboard.
func CopyString(clearClipboardAutomatically bool, copySubject string) error { func CopyBytes(clearClipboardAutomatically bool, copySubject []byte) error {
cmd := exec.Command("termux-clipboard-set") cmd := exec.Command("termux-clipboard-set")
_ = back.WriteToStdin(cmd, copySubject) _ = back.WriteToStdinAndZeroizeInput(cmd, copySubject)
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
return errors.New("unable to copy to clipboard: " + err.Error()) return errors.New("unable to copy to clipboard: " + err.Error())
} }
@@ -25,6 +25,6 @@ func CopyString(clearClipboardAutomatically bool, copySubject string) error {
// getClipCommands returns the commands for pasting and clearing the clipboard contents. // getClipCommands returns the commands for pasting and clearing the clipboard contents.
func getClipCommands() (*exec.Cmd, *exec.Cmd, error) { func getClipCommands() (*exec.Cmd, *exec.Cmd, error) {
cmdClear := exec.Command("termux-clipboard-set") cmdClear := exec.Command("termux-clipboard-set")
_ = back.WriteToStdin(cmdClear, "") _ = back.WriteToStdinAndZeroizeInput(cmdClear, nil)
return exec.Command("termux-clipboard-get"), cmdClear, nil return exec.Command("termux-clipboard-get"), cmdClear, nil
} }
+4 -4
View File
@@ -9,10 +9,10 @@ import (
"github.com/rwinkhart/go-boilerplate/back" "github.com/rwinkhart/go-boilerplate/back"
) )
// CopyString copies a string to the clipboard. // CopyBytes copies a byte slice to the clipboard.
func CopyString(clearClipboardAutomatically bool, copySubject string) error { func CopyBytes(clearClipboardAutomatically bool, copySubject []byte) error {
cmd := exec.Command("clip.exe") cmd := exec.Command("clip.exe")
_ = back.WriteToStdin(cmd, copySubject) _ = back.WriteToStdinAndZeroizeInput(cmd, copySubject)
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
return errors.New("unable to copy to clipboard: " + err.Error()) return errors.New("unable to copy to clipboard: " + err.Error())
} }
@@ -25,6 +25,6 @@ func CopyString(clearClipboardAutomatically bool, copySubject string) error {
// getClipCommands returns the commands for pasting and clearing the clipboard contents. // getClipCommands returns the commands for pasting and clearing the clipboard contents.
func getClipCommands() (*exec.Cmd, *exec.Cmd, error) { func getClipCommands() (*exec.Cmd, *exec.Cmd, error) {
clearCMD := exec.Command("clip.exe") clearCMD := exec.Command("clip.exe")
_ = back.WriteToStdin(clearCMD, "") _ = back.WriteToStdinAndZeroizeInput(clearCMD, nil)
return exec.Command("powershell.exe", "-c", "Get-Clipboard"), clearCMD, nil return exec.Command("powershell.exe", "-c", "Get-Clipboard"), clearCMD, nil
} }
+1 -1
View File
@@ -5,6 +5,6 @@ package clip
// LaunchClearProcess launches the timed clipboard clearing process. // LaunchClearProcess launches the timed clipboard clearing process.
// For interactive GUI/TUI implementations, the clipboard clearing process is launched as a goroutine. // For interactive GUI/TUI implementations, the clipboard clearing process is launched as a goroutine.
// copySubject can be omitted to clear the clipboard immediately and unconditionally. // copySubject can be omitted to clear the clipboard immediately and unconditionally.
func LaunchClearProcess(copySubject string) { func LaunchClearProcess(copySubject []byte) {
go ClearProcess(copySubject) go ClearProcess(copySubject)
} }