mirror of
https://github.com/Threnklyn/advent-of-code-go.git
synced 2026-05-18 19:13:27 +02:00
2020 day 3 - simple 2d grid traversal
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
// CopyToClipboard is for macOS
|
||||
func CopyToClipboard(text string) error {
|
||||
command := exec.Command("pbcopy")
|
||||
command.Stdin = bytes.NewReader([]byte(text))
|
||||
|
||||
if err := command.Start(); err != nil {
|
||||
return fmt.Errorf("error starting pbcopy command: %w", err)
|
||||
}
|
||||
|
||||
err := command.Wait()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error running pbcopy %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user