1. Home
  2. /
  3. Tinygo-wasm
  4. /
  5. TinyGo WASM Multiply Numbers

TinyGo WASM Multiply Numbers - Tinygo-wasm Typing CST Test

Loading…

TinyGo WASM Multiply Numbers — Tinygo-wasm Code

Multiplies two numbers passed from JavaScript and prints the result.

# tinygo/demo/multiply.go
package main

import (
	"syscall/js"
)

func multiply(this js.Value, args []js.Value) interface{} {
	a := args[0].Int()
	b := args[1].Int()
	doc := js.Global().Get("document")
	doc.Call("write", a*b)
	return nil
}

func main() {
	js.Global().Set("multiply", js.FuncOf(multiply))
	select{}
}

Tinygo-wasm Language Guide

TinyGo WebAssembly (tinygo-wasm) is a lightweight Go compiler designed to build extremely small and fast WebAssembly binaries, enabling Go developers to run applications in browsers, edge devices, IoT systems, and embedded environments with minimal resource usage.

Primary Use Cases

  • ▸Running Go code in the browser via WebAssembly
  • ▸IoT and microcontroller applications
  • ▸Edge computing Wasm modules
  • ▸WASI applications in runtimes like wasmtime or wasmer
  • ▸Plugins for serverless Wasm platforms (Spin, Fermyon, WasmCloud, etc.)

Notable Features

  • ▸Very small Wasm binary sizes (10-20× smaller than standard Go)
  • ▸Optimized LLVM-based compiler backend
  • ▸Supports Go core features (structs, interfaces, goroutines via async tasks)
  • ▸Targets browsers, WASI, and embedded hardware
  • ▸Fast compile times and low resource usage

Origin & Creator

TinyGo was created by Ayke van Laethem and the TinyGo community starting in 2018 to make Go viable for microcontrollers, embedded systems, and WebAssembly.

Industrial Note

tinygo-wasm is heavily adopted in constrained environments: IoT, robotics, WebAssembly edge clouds, plugins in serverless Wasm runtimes, and performance-critical Go applications.

More Tinygo-wasm Typing Exercises

Simple TinyGo WASM ProgramTinyGo WASM CounterTinyGo WASM Button ClickTinyGo WASM Hello with InputTinyGo WASM Even CheckTinyGo WASM FibonacciTinyGo WASM Toggle TextTinyGo WASM Add NumbersTinyGo WASM Log Message

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher