golang-wasm

module
v0.0.0-...-7a5c29d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2019 License: MIT

README

Usage

Use the docker image nlepage/golang_wasm:nginx to run a Go program as WebAssembly binary in browser.

Example Dockerfile:

FROM golang:1.11 AS builder

COPY ./ src/app/
RUN GOOS=js GOARCH=wasm go build -o test.wasm app

FROM nlepage/golang_wasm:nginx

COPY --from=builder /go/test.wasm /usr/share/nginx/html/

Build and run then visit http://localhost:32XXX/wasm_exec.html

Examples

Find out about the examples in examples/ or use the image nlepage/golang_wasm:examples to run theses with:

docker container run -dP nlepage/golang_wasm:examples

# Find out which host port is used
docker container ls

Visit http://localhost:32XXX/, and follow the links.

References

Go 1.11: WebAssembly for the gophers

Go WebAssembly: Binding structures to JS references

Directories

Path Synopsis
examples
js

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL