liveBook · Manning

Hello, World program

As explained in Learn Go with Pocket-Sized Projects

A hello, world program is a minimal introductory program that outputs a greeting message.

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

How Learn Go with Pocket-Sized Projects covers it

How deep it goes
Defines the minimal pattern, then extends it to standard-output testing and WebAssembly compilation without developing either topic fully.
Examples
Uses greeting variations, a Go Hello, WASM program, GOOS/GOARCH commands, HTML, JavaScript support, and browser-console output.
What you can do after
Build it from scratch, compile it for WebAssembly, run it in a browser, and recognize its output-oriented structure.
How it connects
Connects program output with standard output, testing, command-line parameters, WebAssembly, JavaScript, browsers, and cross-compilation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Go with Pocket-Sized Projects. The section links point to the parts of the book it draws on.