clipboard icon indicating copy to clipboard operation
clipboard copied to clipboard

Don't panic when headless

Open daonb opened this issue 4 months ago • 1 comments

I've just added you're excellent package to my project and it works great on my arm mac. When I try to run my docker compose based tests it fails to compile:

clipboard_linux.c:15:10: fatal error: X11/Xlib.h: No such file or directory
   15 | #include <X11/Xlib.h>
        |          ^~~~~~~~~~~~
 compilation terminated.

Makes sense - containers don't have X. I've tried disabling CGO and got in run time:

 panic: clipboard: cannot use when CGO_ENABLED=0

It's clear the package can't do anything on a system with no clipboard, but IMHO it should be able to compile and return an error on all calls, leaving it to the calling program to handle. Like in my program's, where I want to use an environment variable as the clipboard storage so I can run and validate clipboard related tests.

daonb avatar Apr 07 '24 11:04 daonb

Reasonable. PR welcome :)

changkun avatar Apr 08 '24 05:04 changkun