wasm

command
v0.0.0-...-6575fa1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

README

WASM

WASM?

WebAssembly (short wasm) is an open standard defined by the W3C. It defines a bytecode for executing programs within web browsers, but can also be used outside of them. The aim of the development was to enable more powerful web applications, both in terms of loading times and execution. The project is supported by all major browser engine developers, ie Mozilla, Microsoft, Google and Apple.

WASM + Go

Go 1.11 (Release Notes) was released in 2018, the first version with support for WebAssembly.

How?

  1. you must have Golang installed.
  2. you must write your application in Go and use the "syscall/js" package. The example is in the wasm.go file.
  3. the .go file must be compiled - this can be done with this command: GOOS=js GOARCH=wasm go build -o cc.wasm wasm.go
  4. so that the browser can do something with the file generated by the Golang compiler, the wasm_exec.js file from the Go toolchain must be provided. cp $(go env GOROOT)/misc/wasm/wasm_exec.js wasm_exec.js
  5. so that the browser can then work with it, the wasm_exec.js and the .wasm file must be integrated/loaded by an HTML file. Example: index.html
  6. the .wasm file must be served with the correct MIME type. Of course, this can also be done using a Golang web server. Example: server.go

All of this can be done by running the bash script init.sh in this directory.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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