Example web application that leverages TinyGo to combine Go language code with a JavaScript web application.
Install Go modules:
$ go mod download$ make demoStart the local web server:
$ go run server.go
Serving ./html on http://localhost:8080Use your web browser to visit http://localhost:8080.
In addition to the JavaScript, it is important the wasm file is served with the
Content-Type
header set to application/wasm. Without it, most browsers won't run it.
This simple server serves anything inside the ./html directory on port
8080, setting any *.wasm files Content-Type header appropriately.
For development purposes (only!), it also sets the Cache-Control header
so your browser doesn't cache the files. This is useful while developing, to
ensure your browser displays the newest wasm when you recompile.
In a production environment you probably wouldn't want to set the
Cache-Control header like this. Caching is generally beneficial for end
users.
Further information on the Cache-Control header can be found here:
MIT License