Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: define Primary on all platforms
Primary was only declared in the Unix build, so setting
clipboard.Primary on Darwin/Windows failed to compile. Move it to the
shared package file so the symbol always exists; it still only affects
X11 PRIMARY selection on Unix.
  • Loading branch information
TastyHeadphones committed Sep 27, 2026
commit 0db9f4eb3391ce2b2f86268ee6959f66dc905f06
6 changes: 6 additions & 0 deletions clipboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ func WriteAll(text string) error {
// Unsupported might be set true during clipboard init, to help callers decide
// whether or not to offer clipboard options.
var Unsupported bool

// Primary controls whether Unix selections use the X11 PRIMARY selection
// instead of CLIPBOARD. On non-Unix platforms Primary has no effect but is
// still defined so cross-compiled code can set it unconditionally.
var Primary bool

1 change: 0 additions & 1 deletion clipboard_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const (
)

var (
Primary bool
trimDos bool

pasteCmdArgs []string
Expand Down
13 changes: 13 additions & 0 deletions primary_export_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package clipboard_test

import (
"testing"

"github.com/atotto/clipboard"
)

func TestPrimaryIsDefined(t *testing.T) {
// Must compile on every GOOS; Primary is a no-op off Unix.
clipboard.Primary = false
_ = clipboard.Primary
}