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
632 stars 68 forks source link

Warn and panic when CGO_ENABLED is set to 0 #11

Closed Dawnnnnnn closed 3 years ago

Dawnnnnnn commented 3 years ago

I'm not sure which library caused the problem. I wrote a demo to verify, it said

   ⨯ release failed after 0.53s error=failed to build for darwin_arm64: exit status 2: # golang.design/x/clipboard
../../../go/pkg/mod/golang.design/x/clipboard@v0.5.1/clipboard.go:90:14: undefined: read
../../../go/pkg/mod/golang.design/x/clipboard@v0.5.1/clipboard.go:110:18: undefined: write
../../../go/pkg/mod/golang.design/x/clipboard@v0.5.1/clipboard.go:125:9: undefined: watch

demo

Any ideas?

changkun commented 3 years ago

You must specify CGO_ENABLED=1 whereas your goreleaser config is:

builds:
  - env:
      - CGO_ENABLED=0
Dawnnnnnn commented 3 years ago

I change CGO_ENABLED= 1 . output:

   ⨯ release failed after 4.12s error=failed to build for linux_386: exit status 2: # runtime/cgo
linux_syscall.c:67:13: error: implicit declaration of function 'setresgid' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
linux_syscall.c:67:13: note: did you mean 'setregid'?
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:593:6: note: 'setregid' declared here
linux_syscall.c:73:13: error: implicit declaration of function 'setresuid' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
linux_syscall.c:73:13: note: did you mean 'setreuid'?
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:595:6: note: 'setreuid' declared here
Dawnnnnnn commented 3 years ago

It seems to be a problem with my local environment, I will try by myself

Dawnnnnnn commented 3 years ago

Although in the end I still can't build the linux version, but this is a bug of musl-cross on Apple silicon,thx a lot

changkun commented 3 years ago

Reopen to give a better error message.