A hello, world program is a minimal introductory program that outputs a greeting. Its practical loop is simple: type, compile, run, and change the message to observe what happens. section 2.0
Hello, WASM!
A Go program can preserve the same minimal shape while targeting WebAssembly: define package main, import fmt, and print a greeting with fmt.Println. Compile it with GOOS=js GOARCH=wasm go build -o main.wasm, then load the result in a browser using Go's WebAssembly support. section 12.1.1
The pattern demonstrates a small but useful development sequence:
- Write a complete program that produces visible output. section 2.0
- Compile for the intended environment, such as a normal machine or WebAssembly. section 12.1.1
- Run the artifact in its required environment and inspect the greeting. section 12.1.1
- Extend the tiny program with documentation and tests, including tests for standard output. section 2.0
Listing 12.1 main.go: Hello, WASM!
package main
import "fmt"
func main() {
fmt.Println("Hello, WASM!")
}
Use the complete Go listing as the smallest runnable form of the pattern before adapting its target platform or greeting. section 12.1.1
