Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Checks if a number is even and prints the result.
# tinygo/demo/even.go
package main
import (
"syscall/js"
)
func isEven(this js.Value, args []js.Value) interface{} {
n := args[0].Int()
result := "Odd"
if n%2 == 0 {
result = "Even"
}
doc := js.Global().Get("document")
doc.Call("write", result)
return nil
}
func main() {
js.Global().Set("isEven", js.FuncOf(isEven))
select{}
}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.
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.