Conversation
|
please check @changkun |
|
I've just seen #13 for the first time, but the problem we want to solve is the same: changing the interface will cause problems for existing applications, so the implementation is backwards compatible.
Checking the implementation in init makes sense and is useful for some users. However, it also narrows down the use cases, and in my opinion, it would be great if the architecture was error-free in import. |
clipboard_linux.go
Outdated
| } | ||
|
|
||
| func readc(t string) ([]byte, error) { | ||
| if !canAccessClipbord && !test() { |
There was a problem hiding this comment.
Could you elaborate more on why do we need this check at every call?
|
We believe that if you can access clipbord once, you can always access it a second time or later. Therefore, to eliminate the overhead, we use canAccessClipbord to manage it. |
I think if one can pass Init(), then the system environment is sufficient to access clipboard information. However, indeed it may fail at some point for some reason. But as the current API is designed to behave: if there is an error when accessing the clipboard, it returns nothing and one may retry calling it afterward. Panic after the success of Init is an undesired behavior as discussed in #19. |
If you are using Linux without X11 enabled, an error will occur at the time of import.
Add Test() methods to check if the clipboard is accessible for conditional branching.
Fixes #19