webview / webview_go

Go language bindings for the webview library.
MIT License
176 stars 27 forks source link

Can not build: Build constraints exclude all Go files #38

Open PritishMishraa opened 3 months ago

PritishMishraa commented 3 months ago

can not build when running the command GOOS=darwin GOARCH=amd64 go build

error: github.com/webview/webview_go: build constraints exclude all Go files in /Users/pritishmishra/go/pkg/mod/github.com/webview/webview_go@v0.0.0-20240220051247-56f456ca3a43

but the go build command works. if I do this go build .

my go env:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/pritishmishra/Library/Caches/go-build'
GOENV='/Users/pritishmishra/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/pritishmishra/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/pritishmishra/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.1'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/pritishmishra/Documents/Projects/sql-editor/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/60/92p0hs5x0v5fsfw5hfmpwbm80000gn/T/go-build4183224487=/tmp/go-build -gno-record-gcc-switches -fno-common'

go version: go version go1.22.1 darwin/arm64 g++ version: Apple clang version 15.0.0 (clang-1500.3.9.4) Target: arm64-apple-darwin23.4.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin

terrywh commented 3 months ago

same problem on windows.

> go build -ldflags="-H windowsgui" ./cmd/test
github.com/webview/webview_go: build constraints exclude all Go files in C:\Users\*\go\pkg\mod\github.com\webview\webview_go@v0.0.0-20240220051247-56f456ca3a43

after a while googling, using the following fix things for me (but only for a while 😭):

go clean -modcache
W1M0R commented 1 month ago

You may also need to set the CGO_ENABLED=1 environment variable if you are doing cross-compilation. Also be sure to have the necessary cross-compilation toolchain on your system and that your CC and CCX environment variables are using the correct toolchains: https://github.com/webview/webview_go/issues/18#issuecomment-1851966915