Go developers can benefit from WebAssembly and WasmEdge Runtime in two important ways. You can compile Go programs to run in the WasmEdge container, or embed external functions, written in multiple programming languages, into Go applications as plug-ins. Get started by installing WasmEdge or using the WasmEdge development Docker.
Embed WasmEdge in Go applications
- Tutorial on how to embed WebAssembly functions in Go host applications
- Examples and demos on how to use the WasmEdge Go SDK
- Go SDK API reference guide coming soon!
Integrations and use cases:
- YoMo: Streaming image recognition using WebAssembly embedded functions (Tutorial | Source code)
- Dapr: Creating microservices (Tutorial | Source code)
- Reactr: An easy-to-use framework to embed WasmEdge functions into Go applications (Source code)
- MOSN: A service mesh API proxy that can be extended by WasmEdge programs – coming soon!
The standard Go plug-in system is based on shared libraries and has many issues. The plug-in is not isolated from the host and hence is not safe. The WasmEdge approach allows safe mixing of plug-ins written in different languages for different systems.
Run Go programs in WasmEdge
WebAssembly is a ploygot runtime that supports many front-end programming languages. Compiling your Go program to WebAssembly allows the Go program to run efficiently and safely across all OS and hardware platforms WasmEdge supports. It is more secure and portable than the default native client (NaCl) compiling targets for Go programs. It allows Go applications to be easily managed by container tools such as Kubernetes without the overhead of Docker and guest Linux. WasmEdge also makes it possible to embed Go functions into other applications (e.g., a Go host app as above or a Node.js host app).
However, it is still difficult to run standard Go programs without change to WebAssembly since Go requires a runtime enviornment that handles issues like GC. If you would like to create a Go runtime for WebAssembly, please get in touch! We would like to see that!