golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.36k stars 17.71k forks source link

Build wasm failed, but build go binary is work #63638

Closed Rory-Z closed 1 year ago

Rory-Z commented 1 year ago

What version of Go are you using (go version)?

$ go version
go version go1.21.3 darwin/amd64

Does this issue reproduce with the latest release?

Yes, the this issue reproduce in the 1.21.3

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE='on'
GOARCH='amd64'
GOBIN='/Users/somebody/go/bin'
GOCACHE='/Users/somebody/Library/Caches/go-build'
GOENV='/Users/somebody/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/somebody/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/somebody/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/somebody/sdk/go1.21.3'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/somebody/sdk/go1.21.3/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.21.3'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/somebody/WorkSpace/Code/emqx-operator/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 x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/ld/kvctdxw97tx6y4kh1h4xgn8m0000gn/T/go-build2310576829=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

I want build wasm like this blog: https://go.dev/blog/wasi, but I got this error:

$ GOOS=wasip1 GOARCH=wasm  go build -a -o manager.wasm main.go
# sigs.k8s.io/controller-runtime/pkg/certwatcher
../../../go/pkg/mod/sigs.k8s.io/controller-runtime@v0.12.3/pkg/certwatcher/certwatcher.go:97:34: cw.watcher.Events undefined (type *fsnotify.Watcher has no field or method Events)
../../../go/pkg/mod/sigs.k8s.io/controller-runtime@v0.12.3/pkg/certwatcher/certwatcher.go:105:32: cw.watcher.Errors undefined (type *fsnotify.Watcher has no field or method Errors)

but when I build go binary, looks good

$ go build -a -o manager main.go && echo $?
0

the code is from https://github.com/emqx/emqx-operator, I'm this repo owner, but I just want learning wasm, so can ignore this repo.

What did you expect to see?

I want build wasm successfully

What did you see instead?

seankhliao commented 1 year ago

looks like the library doesn't support the platform.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions