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.16. Please check your golang version before installation. You can download golang here.

  1. $ go version
  2. go version go1.16.5 linux/amd64

Meantime, please make sure you have installed the WasmEdge shared library with the same WasmEdge-go release version.

  1. curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -v 0.10.0

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

  1. curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -v 0.10.0 -e tensorflow,image

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:

  1. go get github.com/second-state/WasmEdge-go/wasmedge@v0.10.0
  2. 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.

    • To install the tensorflow extension, please use the -e tensorflow flag in the WasmEdge installer command.

    • For using this extension, the tag tensorflow when building is required:

      1. go build -tags tensorflow
  • Image

    • This extension supports the host functions in WasmEdge-image.

    • To install the image extension, please use the -e image flag in the WasmEdge installer command.

    • For using this extension, the tag image when building is required:

      1. go build -tags image

You can also turn on the multiple extensions when building:

  1. go build -tags image,tensorflow

For examples, please refer to the example repository.

WasmEdge AOT Compiler in Go

The go_WasmAOT example demonstrates how to compile a WASM file into a native binary (AOT compile) from within a Go application.

Examples