golang-design / clipboard

📋 cross-platform clipboard package that supports accessing text and image in Go (macOS/Linux/Windows/Android/iOS)
https://golang.design/x/clipboard
MIT License
579 stars 64 forks source link

fix linux initialization bug. #33

Closed bw31642 closed 1 year ago

bw31642 commented 1 year ago

make initX11() return 0 in the event of dlopen failing. This allows the test for failure in clipboard_test() to work as expected.

changkun commented 1 year ago

I am not sure why this is a bug. Returning -1 indicates there is something wrong with the system, and we should not proceed with using the package. Are you saying that without loading libX11.so, the package can still work as expected?

bw31642 commented 1 year ago

I'm saying the test in the function clipboard_test() of clipboard_linux.c needs a 0 to get to the return -1. 0 is the only value that means false. int clipboard_test() { if (!initX11()) { <----------- This needs a return value of 0 to get to the return -1 return -1; } If you test the code when libX11.so is not available, you can observe the error.