Skip to content

tderflinger/tinygo-webapp-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tinygo-webapp-demo

Example web application that leverages TinyGo to combine Go language code with a JavaScript web application.

Building

Install Go modules:

$ go mod download
$ make demo

Running

Start the local web server:

$ go run server.go
Serving ./html on http://localhost:8080

Use 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:

License

MIT License

Releases

No releases published

Packages

No packages published