# wasm-example **Repository Path**: chanterchen/wasm-example ## Basic Information - **Project Name**: wasm-example - **Description**: go编译wasm示例 - **Primary Language**: Go - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-04-07 - **Last Updated**: 2026-04-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Go WebAssembly Example This project demonstrates how to write WebAssembly programs using the Go language and run them in a browser or Node.js environment. ## Features - **hello** function: Returns the classic "Hello, World!" greeting - Supports running WebAssembly modules in modern browsers - Supports running in Node.js environments ## Prerequisites - Go 1.17 or higher - A modern browser with WebAssembly support or Node.js ## Build and Run ### Browser Environment 1. Build the WASM module: ```bash make # Or manually execute: go build -o hello.wasm main.go ``` 2. Start a local server (e.g., using Go's http.server): ```bash go run -exec=go run main.go # Or use any other HTTP server to serve index.html ``` 3. Access `index.html` in your browser ### Node.js Environment ```bash node wasm_exec_node.js ``` ## Project Structure ``` . ├── main.go # Go source code ├── hello.wasm # Compiled WebAssembly file ├── index.html # HTML entry page ├── wasm_exec.js # WebAssembly loader for browser ├── wasm_exec_node.js # WebAssembly loader for Node.js ├── makefile # Build script ├── go.mod # Go module definition └── LICENSE # License ``` ## License MIT License