clipboard icon indicating copy to clipboard operation
clipboard copied to clipboard

Clipboard crashing on MacOS

Open rabbah opened this issue 8 months ago • 0 comments

I'm encountering a crash on in clipboard initialization on a mac and wondering if anyone else has seen this. Here's a simple program.

package main

import (
	"fmt"
	"log"
	"golang.design/x/clipboard"
)

func main() {
	// Initialize the clipboard
	err := clipboard.Init()
	if err != nil {
		log.Fatal(err)
	}

	// Text to copy to clipboard
	text := "Hello from Go clipboard!"

	// Copy text to clipboard
	clipboard.Write(clipboard.FmtText, []byte(text))

	fmt.Println("Copied to clipboard:", text)
}

This run with go run:

> go run src/main.go 
Copied to clipboard: Hello from Go clipboard!

But is killed when compiled to a binary

> go build src/main.go 
Killed: 9

gclip crashes in a similar way. I suspect a change in one of the dependencies but not sure which yet.

Compiling with latest go version 1.24.1 (as of when this issue was created) solved the problem.

rabbah avatar Mar 24 '25 01:03 rabbah