Skip to content
Learn Netverks

Lesson

Step 6/36 17% through track

hello-world-go

Hello, World in Go

Last reviewed May 28, 2026 Content v20260528
Track mode
server_compiled
Means
Compiled runner
Reading
~1 min
Level
beginner

This lesson

This lesson teaches Hello, World in Go: the syntax, patterns, and safety habits you need before advancing in Go.

Teams still ship Hello, World in Go in Go codebases—skipping it leaves gaps in debugging and code reviews.

You will apply Hello, World in Go in contexts like: Kubernetes ecosystem tools, cloud APIs, and CLI utilities.

Write Go in main.go with package main and func main(), click Run on server—the dev runner runs go run main.go; use fmt.Println for output (requires Go toolchain; LEARNING_RUNNER_ENABLED=true). Also use package main, func main(), and fmt.Println; exported names start with a capital letter.

When you can explain the previous lesson's ideas without copying starter code.

Every Go executable starts with package main and a func main() entry point. Output uses the fmt package—similar to System.out.println in Java or print() in Python, but requires an explicit import.

Minimal program

package main

import "fmt"

func main() {
    fmt.Println("Hello, World")
}

fmt.Println writes to stdout with a trailing newline. Use fmt.Print when you control line endings yourself.

Imports and formatting

Go requires imports for standard library packages. Unused imports are compile errors—delete them or use the value. go fmt standardizes indentation (tabs) and import grouping.

Important interview questions and answers

  1. Q: What prints text in Go?
    A: fmt.Println, fmt.Printf, and fmt.Print from the fmt package.
  2. Q: Can you run code without main?
    A: Libraries use package somethingelse; only package main with func main() builds an executable.

Self-check

  1. Which keyword declares the executable package?
  2. What happens if you import fmt but never use it?

Tip: Every executable needs package main and func main()—unlike Python scripts that run top-level statements without an entry point.

Interview prep

What prints text?

fmt.Println and fmt.Printf from the imported fmt package.

Entry point?

func main() in package main—required for executables.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • fmt import?
  • Unused import error?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump