Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pascalallen/wasm-go
wasm-go is a module that is designed to compile a WebAssembly module from Go. There is a publication for this repository which can be found at https://pascalallen.medium.com/how-to-compile-a-webassembly-module-from-go-a9ed5f831582.
https://github.com/pascalallen/wasm-go
go webassembly
Last synced: 8 days ago
JSON representation
wasm-go is a module that is designed to compile a WebAssembly module from Go. There is a publication for this repository which can be found at https://pascalallen.medium.com/how-to-compile-a-webassembly-module-from-go-a9ed5f831582.
- Host: GitHub
- URL: https://github.com/pascalallen/wasm-go
- Owner: pascalallen
- Created: 2023-07-02T16:11:09.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-01T14:06:22.000Z (12 months ago)
- Last Synced: 2024-06-20T22:25:25.821Z (5 months ago)
- Topics: go, webassembly
- Language: Go
- Homepage:
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# wasm-go
wasm-go is a module that is designed to compile a WebAssembly module from Go. There is a publication for this repository which can be found [here](https://pascalallen.medium.com/how-to-compile-a-webassembly-module-from-go-a9ed5f831582).
## Prerequisites
- [Go](https://go.dev/dl/)
## WebAssembly Compilation Steps
### Compile the project's Go module to WebAssembly
```bash
cd app/ && GOOS=js GOARCH=wasm go build -o ../public/app.wasm
```### Copy the compiled JavaScript WebAssembly support file to the project
```bash
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ../public/app.js
```### Run the project's web server from project root
```bash
go run webserver.go
```Navigate to [http://localhost:9990/](http://localhost:9990/), open the JavaScript debug console, and you should
see the output. You can modify the program, rebuild `app.wasm`, and refresh to see new output.