Skip to content

Clipboard crashing on MacOS #71

@rabbah

Description

@rabbah

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions