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

Can add some function let us know the bytes is image or text #24

Closed 52funny closed 2 years ago

52funny commented 2 years ago

Hi, @changkun Thank you to create the wonderful framework. Can you provide a way for us to read the clipboard content as a stream of characters or images?

Like this

func IsText() bool
func IsImage() bool
changkun commented 2 years ago

Hi I don't think you need additional APIs to check if the data is text or image, if you try

clipboard.Read(clipboard.FmtText)

But the actual content in clipboard is image, the call returns you a nil, same applied to image.

Regarding reading as a stream of characters, I don't know enough about the purpose of it. If you just need convert []byte to io.Reader, you could try bytes.NewReader. Can you elaborate more?

changkun commented 2 years ago

Lack of information. Close.