Scripts2026年7月3日·1 分钟阅读

wazero — Zero-Dependency WebAssembly Runtime for Go

A WebAssembly runtime written in pure Go with zero dependencies. Embed Wasm modules in Go applications without CGo, system libraries, or JIT compilation.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
wazero
直接安装命令
npx -y tokrepo@latest install 3be66130-771e-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

wazero is a WebAssembly runtime for Go developers that has zero platform dependencies. It compiles to pure Go with no CGo bindings, making it easy to cross-compile and deploy anywhere Go runs. It supports both an interpreter and an ahead-of-time compiler for balancing portability with performance.

What wazero Does

  • Runs WebAssembly modules inside Go applications without external dependencies
  • Supports WASI preview 1 for filesystem, environment, and I/O operations
  • Provides both interpreter and ahead-of-time (AOT) compilation modes
  • Implements the WebAssembly 2.0 core specification
  • Embeds as a Go library with a clean, idiomatic API

Architecture Overview

wazero implements two execution engines: an interpreter for maximum portability and an AOT compiler that translates Wasm bytecode to native machine code at load time. Both engines share the same module instantiation and memory management code. The runtime manages linear memory, tables, and globals per the Wasm spec. Host functions can be registered to expose Go functionality to Wasm modules.

Self-Hosting & Configuration

  • Add wazero as a Go module dependency with go get
  • Instantiate a runtime, compile a Wasm module, and call exported functions
  • Choose between interpreter mode (maximum compatibility) and compiler mode (faster execution)
  • Register host functions to expose Go APIs to Wasm guest code
  • Configure memory limits, WASI options, and filesystem access through the API

Key Features

  • Pure Go with zero CGo or system library dependencies
  • Cross-compiles to every platform Go supports without build toolchain changes
  • Two execution modes: interpreter for portability, AOT compiler for performance
  • Full WASI preview 1 support with configurable filesystem and environment
  • Compliant with the WebAssembly 2.0 core specification

Comparison with Similar Tools

  • Wasmtime — Rust/C-based JIT runtime vs. pure Go with no native dependencies
  • wasm3 — C-based universal interpreter vs. Go-native with AOT compilation option
  • WasmEdge — C++-based cloud runtime vs. embeddable Go library
  • Extism — plugin framework on top of runtimes vs. raw runtime you build plugins with

FAQ

Q: Why choose wazero over Wasmtime with Go bindings? A: wazero has no CGo dependency, which simplifies cross-compilation, reduces binary size, and avoids CGo-related build complexity.

Q: How fast is the AOT compiler compared to the interpreter? A: The AOT compiler is typically 10-50x faster than the interpreter for compute-intensive workloads, with compilation adding a one-time startup cost.

Q: Can I use wazero for plugin systems? A: Yes. Many Go projects use wazero to run untrusted Wasm plugins in a sandboxed environment with controlled host function access.

Q: Does it support the component model? A: wazero currently supports the core WebAssembly specification. Component model support is being tracked but not yet implemented.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产