无法识别的导入路径 "syscall/js"
unrecognized import path "syscall/js"
我正在尝试使用 webassembly 但我不能 运行 这个
import (
"syscall/js"
)
或
GOARCH=wasm GOOS=js go get -u github.com/siongui/godom/wasm
安装 wasm
它抛出一个错误
cannot find package "syscall/js" in any of:
我使用的是go版本go1.6.2linux
Go 1.11 Release Notes (August 2018)
Go programs can call into JavaScript using the new experimental
syscall/js
package.
syscall/js
首次在 Go1.11(2018 年 8 月)中引入。命令 go version
的输出是 go1.6.2 l
,一个古老的(2016 年 2 月)和过时的版本。
从 Go Downloads, please follow the installation instructions, including the instructions for Uninstalling Go 下载适合您系统的 Go1.11 或更高版本的二进制版本后,适用于您当前的 Go 版本。
Go1.12 在 syscall/js
中有一些重大变化
The Callback
type and NewCallback
function have been renamed; they are now called Func
and FuncOf
, respectively. This is a breaking change, but WebAssembly support is still experimental and not yet subject to the Go 1 compatibility promise. Any code using the old names will need to be updated.
If a type implements the new Wrapper interface, ValueOf
will use it to return the JavaScript value for that type.
The meaning of the zero Value
has changed. It now represents the JavaScript undefined value instead of the number zero. This is a breaking change, but WebAssembly support is still experimental and not yet subject to the Go 1 compatibility promise. Any code relying on the zero Value to mean the number zero will need to be updated.
The new Value.Truthy
method reports the JavaScript "truthiness" of a given value.
这里有一个 link 的示例,使用 React、Node 和 Go 来获得更清晰的理解。
我正在尝试使用 webassembly 但我不能 运行 这个
import (
"syscall/js"
)
或
GOARCH=wasm GOOS=js go get -u github.com/siongui/godom/wasm
安装 wasm
它抛出一个错误
cannot find package "syscall/js" in any of:
我使用的是go版本go1.6.2linux
Go 1.11 Release Notes (August 2018)
Go programs can call into JavaScript using the new experimental
syscall/js
package.
syscall/js
首次在 Go1.11(2018 年 8 月)中引入。命令 go version
的输出是 go1.6.2 l
,一个古老的(2016 年 2 月)和过时的版本。
从 Go Downloads, please follow the installation instructions, including the instructions for Uninstalling Go 下载适合您系统的 Go1.11 或更高版本的二进制版本后,适用于您当前的 Go 版本。
Go1.12 在 syscall/js
中有一些重大变化The
Callback
type andNewCallback
function have been renamed; they are now calledFunc
andFuncOf
, respectively. This is a breaking change, but WebAssembly support is still experimental and not yet subject to the Go 1 compatibility promise. Any code using the old names will need to be updated.If a type implements the new Wrapper interface,
ValueOf
will use it to return the JavaScript value for that type.The meaning of the zero
Value
has changed. It now represents the JavaScript undefined value instead of the number zero. This is a breaking change, but WebAssembly support is still experimental and not yet subject to the Go 1 compatibility promise. Any code relying on the zero Value to mean the number zero will need to be updated.The new
Value.Truthy
method reports the JavaScript "truthiness" of a given value.
这里有一个 link 的示例,使用 React、Node 和 Go 来获得更清晰的理解。