Use Tinygo to convert Golang to WASM and use in a HTML page with JavaScript.
The project uses NodeJS version 20 to run a demo HTTP server.
$ git clone https://github.com/rmarchet/tinygo-wasm-js.git
And then move into the project directory to run the commands in the following paragraphs:
$ cd tinygo-wasm-js
Follow the proper guide for your OS:
https://tinygo.org/getting-started/install/
Make sure that TinyGO works:
$ tinygo version
$ yarn install
or
$ npm install
$ yarn build
or
$ npm run build
If everithing goes fine, the main.wasm is created in the ./httpdocs folder
This demo project comes with browsersync which runs a local HTTP server and reloads the page everytime there's a change in the files. To start the server simply run:
$ yarn start
or
$ npm run start
and then visit http://localhost:8088 using your preferred browser.