Description
What version of Go are you using (go version
)?
$ go version go version go1.14 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/Users/mkunc/Library/Caches/go-build" GOENV="/Users/mkunc/Library/Application Support/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/mkunc/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/mkunc/go/src/github.com/martinkunc/wagather/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/nw/2584cxnn0_545f3kzf2g8mlw0000gn/T/go-build220972923=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
I am running Golang WebAssembly in Wasmer. In Go 1.14 the application fails on panic: bad type flag
, but in Go 1.13 it runs well. The application is importing "syscall/js".
What is failing:
I believe it is failing because throwing panic was added in Go 1.14:
https://github.com/golang/go/blob/master/src/syscall/js/js.go#L291
In Go 1.13.9, it by default considers the object type to be js object:
https://github.com/golang/go/blob/go1.13.9/src/syscall/js/js.go#L244
But I believe the real problem is to expect javascript runtime having fs.constants of some type,
which I believe is happening here:
https://github.com/golang/go/blob/master/src/syscall/fs_js.go#L21
Unfortunatelly this syscall variable requires the constant exists before initialization, so I cannot set it before importing "syscall/js"
My humble opinion would be that we could change constants to fsConstants function() {} so that it would be evaluated only when particular fs function would require it (and I would have chance to set it up upfront on another environment).
What did you expect to see?
Application runs fine.
What did you see instead?
Application crashes with:
panic: bad type flag
goroutine 1 [running]:
syscall/js.Value.Type(0x7ff800000000000b, 0x0, 0x0)
/usr/local/go/src/syscall/js/js.go:291 +0x1b
syscall/js.Value.Get(0x7ff800000000000b, 0x0, 0x2873f8, 0x9, 0x7ff800000000000b, 0x0)
/usr/local/go/src/syscall/js/js.go:298 +0x2
syscall.init()
/usr/local/go/src/syscall/fs_js.go:21 +0xe