WasmEdge Go SDK

The followings are the guides to working with the WasmEdge Go API. You can embed the WasmEdge into your go application through the WasmEdge Go API.

Getting Started

The WasmEdge-go requires golang version >= 1.15. Please check your golang version before installation. Developers can download golang here.

$ go version
go version go1.16.5 linux/amd64

Developers must install the WasmEdge shared library with the same WasmEdge-go release version.

wget -qO- https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -v 0.9.0-rc.4

For more details, please refer to the Installation Guide for the WasmEdge installation.

For the developers need the TensorFlow or Image extension for WasmEdge-go, please install the WasmEdge with extensions:

wget -qO- https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -v 0.9.0-rc.4

Noticed that the TensorFlow and Image extensions are only for the Linux platforms.

Install the WasmEdge-go package and build in your Go project directory:

$ go get github.com/second-state/WasmEdge-go/wasmedge@v0.9.0-rc3
$ go build

WasmEdge-go Extensions

By default, the WasmEdge-go only turns on the basic runtime.

WasmEdge-go has the following extensions:

  • Tensorflow
    • This extension supports the host functions in WasmEdge-tensorflow.
    • The TensorFlow extension when installing WasmEdge is required. Please install WasmEdge with the -e tensorflow command.
    • For using this extension, the tag tensorflow when building is required:
      $ go build -tags tensorflow
      
  • Image
    • This extension supports the host functions in WasmEdge-image.
    • The Image extension when installing WasmEdge is required. Please install WasmEdge with the -e image command.
    • For using this extension, the tag image when building is required:
      $ go build -tags image
      

Users can also turn on the multiple extensions when building:

$ go build -tags image,tensorflow

For examples, please refer to the example repository.

WasmEdge AOT Compiler in Go

The go_WasmAOT example provide a tool for compiling a WASM file into compiled-WASM for AOT mode.

Examples