dongliang1893
dongliang1893
2018-11-26 00:27
浏览 607
已采纳

无法识别的导入路径“ syscall / js”

I am trying to use webassembly but I can't run this

import (
    "syscall/js"
)

or

GOARCH=wasm GOOS=js go get -u github.com/siongui/godom/wasm

to install wasm

It throws me an error

cannot find package "syscall/js" in any of:

I am using go version go1.6.2 linux

图片转代码服务由CSDN问答提供 功能建议

我正在尝试使用网络汇编,但无法运行

   import(
“ syscall / js” 
)
   
 
 

  GOARCH = wasm  GOOS = js go -u github.com/siongui/godom/wasm
  
 
 

安装wasm

错误

 在以下任何位置都找不到软件包“ syscall / js”:
   
 
 

我正在使用go版本 go1.6.2 linux

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douzhang5121
    douzhang5121 2018-11-26 00:49
    已采纳

    Go 1.11 Release Notes (August 2018)

    WebAssembly

    Go programs can call into JavaScript using the new experimental syscall/js package.


    syscall/js was first introduced in Go1.11 (August 2018). Your output from the command go version is go1.6.2 l, an ancient (February 2016) and obsolete version.


    After downloading a binary release of Go1.11 or later suitable for your system from Go Downloads, please follow the installation instructions, including the instructions for Uninstalling Go for your current version of Go.

    点赞 评论
  • doulu7258
    doulu7258 2019-03-04 23:20

    There are some breaking changes in Go1.12 in 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.


    Here is a link to an example that uses React, Node and Go to get a clearer understanding.

    https://github.com/phmatray/webassembly-demo

    点赞 评论

相关推荐