Edit the Go example below and click Run to preview expected output notes.
Go Tutorial
Learn Go Tutorial with a small example you can edit and run.
go version
go run .
Edit the Go code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
package main | Declares the package name. |
import "fmt" | Imports packages (like fmt). |
func main() { | Program entry point. |
fmt.Println("Welcome to Go") | Outputs text using fmt. |
} | Go line. |
- 1Go is used for backend services, CLIs, and cloud tooling.
- 1Ignoring error handling and writing huge functions.
- 1Keep functions small and handle errors explicitly.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Go Golang Go TutorialGo Home
Learn Go Home with a small example you can edit and run.
go version
go run .
Edit the Go code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
package main | Declares the package name. |
import "fmt" | Imports packages (like fmt). |
func main() { | Program entry point. |
fmt.Println("Welcome to Go") | Outputs text using fmt. |
} | Go line. |
- 1Go is used for backend services, CLIs, and cloud tooling.
- 1Ignoring error handling and writing huge functions.
- 1Keep functions small and handle errors explicitly.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Go Golang Go HomeGo Introduction
Learn Go Introduction with a small example you can edit and run.
go version
go run .
Edit the Go code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
package main | Declares the package name. |
import "fmt" | Imports packages (like fmt). |
func main() { | Program entry point. |
fmt.Println("Welcome to Go") | Outputs text using fmt. |
} | Go line. |
- 1Go is used for backend services, CLIs, and cloud tooling.
- 1Ignoring error handling and writing huge functions.
- 1Keep functions small and handle errors explicitly.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Go Golang Go IntroductionGo Get Started
Learn Go Get Started with a small example you can edit and run.
go version
go run .
Edit the Go code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
package main | Declares the package name. |
import "fmt" | Imports packages (like fmt). |
func main() { | Program entry point. |
fmt.Println("Welcome to Go") | Outputs text using fmt. |
} | Go line. |
- 1Go is used for backend services, CLIs, and cloud tooling.
- 1Ignoring error handling and writing huge functions.
- 1Keep functions small and handle errors explicitly.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Go Golang Go Get StartedGo Syntax
Learn Go Syntax with a small example you can edit and run.
package main
import "fmt"
func main() {
fmt.Println("Hello")
}
Edit the Go code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
package main | Declares the package name. |
import "fmt" | Imports packages (like fmt). |
func main() { | Program entry point. |
score := 82 | Declares/initializes variables. |
result := "Fail" | Declares/initializes variables. |
if score >= 75 { | Conditional branch. |
result = "Pass" | Go line. |
} | Go line. |
fmt.Println(result) | Outputs text using fmt. |
} | Go line. |
- 1Go is used for backend services, CLIs, and cloud tooling.
- 1Ignoring error handling and writing huge functions.
- 1Keep functions small and handle errors explicitly.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Go Golang Go SyntaxGo Output
Learn Go Output with a small example you can edit and run.
fmt.Print("Hi")
fmt.Println(" Go")
fmt.Printf("n=%d\n", n)
Edit the Go code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
package main | Declares the package name. |
import "fmt" | Imports packages (like fmt). |
func main() { | Program entry point. |
fmt.Print("Hi") | Outputs text using fmt. |
fmt.Print(" ") | Outputs text using fmt. |
fmt.Println("Go") | Outputs text using fmt. |
} | Go line. |
- 1Go is used for backend services, CLIs, and cloud tooling.
- 1Ignoring error handling and writing huge functions.
- 1Keep functions small and handle errors explicitly.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Go Golang Go OutputGo Comments
Learn Go Comments with a small example you can edit and run.
// single-line
/* multi-line */
Edit the Go code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
package main | Declares the package name. |
import "fmt" | Imports packages (like fmt). |
func main() { | Program entry point. |
/* multi-line | Go line. |
comment */ | Go line. |
fmt.Println("Comments don't change output") | Outputs text using fmt. |
} | Go line. |
- 1Go is used for backend services, CLIs, and cloud tooling.
- 1Ignoring error handling and writing huge functions.
- 1Keep functions small and handle errors explicitly.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Go Golang Go CommentsGo Variables
Learn Go Variables with a small example you can edit and run.
var name string = "Mana"
age := 21
Edit the Go code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
package main | Declares the package name. |
import "fmt" | Imports packages (like fmt). |
func main() { | Program entry point. |
name := "Mana" | Declares/initializes variables. |
age := 21 | Declares/initializes variables. |
age = age + 1 | Go line. |
fmt.Printf("%s is %d years old\n", name, age) | Outputs text using fmt. |
} | Go line. |
- 1Go is used for backend services, CLIs, and cloud tooling.
- 1Ignoring error handling and writing huge functions.
- 1Keep functions small and handle errors explicitly.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Go Golang Go VariablesGo Constants
Learn Go Constants with a small example you can edit and run.
const Pi = 3.14159
Edit the Go code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
package main | Declares the package name. |
import "fmt" | Imports packages (like fmt). |
const Max = 100 | Declares a constant. |
func main() { | Program entry point. |
fmt.Println(Max) | Outputs text using fmt. |
} | Go line. |
- 1Go is used for backend services, CLIs, and cloud tooling.
- 1Ignoring error handling and writing huge functions.
- 1Keep functions small and handle errors explicitly.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Go Golang Go ConstantsGo Data Types
Learn Go Data Types with a small example you can edit and run.
var a int = 7
var b float64 = 3.14
var ok bool = true
Edit the Go code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
package main | Declares the package name. |
import "fmt" | Imports packages (like fmt). |
func main() { | Program entry point. |
var a int = 10 | Declares/initializes variables. |
var b float64 = 3.5 | Declares/initializes variables. |
var ok bool = true | Declares/initializes variables. |
var c rune = 'A' | Declares/initializes variables. |
fmt.Println(a) | Outputs text using fmt. |
fmt.Println(b) | Outputs text using fmt. |
fmt.Println(ok) | Outputs text using fmt. |
fmt.Println(string(c)) | Outputs text using fmt. |
} | Go line. |
- 1Go is used for backend services, CLIs, and cloud tooling.
- 1Ignoring error handling and writing huge functions.
- 1Keep functions small and handle errors explicitly.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Go Golang Go Data TypesGo Operators
Learn Go Operators with a small example you can edit and run.
sum := a + b
mod := a % b
ok := a > b && b > 0
Edit the Go code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
package main | Declares the package name. |
import "fmt" | Imports packages (like fmt). |
func main() { | Program entry point. |
a := 7 | Declares/initializes variables. |
b := 3 | Declares/initializes variables. |
fmt.Println(a + b) | Outputs text using fmt. |
} | Go line. |
- 1Go is used for backend services, CLIs, and cloud tooling.
- 1Ignoring error handling and writing huge functions.
- 1Keep functions small and handle errors explicitly.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Go Golang Go OperatorsGo Arrays
Learn Go Arrays with a small example you can edit and run.
a := [4]int{1,2,3,4}
Edit the Go code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
package main | Declares the package name. |
import "fmt" | Imports packages (like fmt). |
func main() { | Program entry point. |
nums := [4]int{1, 2, 3, 4} | Declares/initializes variables. |
sum := 0 | Declares/initializes variables. |
for _, x := range nums { | Declares/initializes variables. |
sum += x | Go line. |
} | Go line. |
fmt.Println(sum) | Outputs text using fmt. |
} | Go line. |
- 1Data structures model your API payloads, configs, and in-memory state.
- 1Using arrays when you need slices, or forgetting map key checks.
- 1Prefer slices for dynamic lists; validate map lookups when needed.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Go Golang Go ArraysGo Slices
Learn Go Slices with a small example you can edit and run.
s := []int{1,2,3}
s = append(s, 4)
Edit the Go code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
package main | Declares the package name. |
import "fmt" | Imports packages (like fmt). |
func main() { | Program entry point. |
s := []int{1, 2, 3} | Declares/initializes variables. |
s = append(s, 4) | Appends to a slice. |
fmt.Println(len(s)) | Outputs text using fmt. |
} | Go line. |
- 1Data structures model your API payloads, configs, and in-memory state.
- 1Using arrays when you need slices, or forgetting map key checks.
- 1Prefer slices for dynamic lists; validate map lookups when needed.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Go Golang Go SlicesGo Struct
Learn Go Struct with a small example you can edit and run.
type User struct { Name string }
Edit the Go code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
package main | Declares the package name. |
import "fmt" | Imports packages (like fmt). |
type User struct { | Declares a struct type. |
Name string | Go line. |
Level int | Go line. |
} | Go line. |
func main() { | Program entry point. |
u := User{Name: "Mana", Level: 2} | Declares/initializes variables. |
fmt.Println(u.Name) | Outputs text using fmt. |
} | Go line. |
- 1Data structures model your API payloads, configs, and in-memory state.
- 1Using arrays when you need slices, or forgetting map key checks.
- 1Prefer slices for dynamic lists; validate map lookups when needed.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Go Golang Go StructGo Maps
Learn Go Maps with a small example you can edit and run.
m := map[string]int{"SQL": 2}
fmt.Println(m["SQL"])
Edit the Go code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
package main | Declares the package name. |
import "fmt" | Imports packages (like fmt). |
func main() { | Program entry point. |
m := map[string]int{"Go": 1, "SQL": 2} | Declares/initializes variables. |
fmt.Println(m["SQL"]) | Outputs text using fmt. |
} | Go line. |
- 1Data structures model your API payloads, configs, and in-memory state.
- 1Using arrays when you need slices, or forgetting map key checks.
- 1Prefer slices for dynamic lists; validate map lookups when needed.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Go Golang Go MapsGo Conditions
Learn Go Conditions with a small example you can edit and run.
if n > 0 {
fmt.Println("pos")
} else {
fmt.Println("non-pos")
}
Edit the Go code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
package main | Declares the package name. |
import "fmt" | Imports packages (like fmt). |
func main() { | Program entry point. |
score := 75 | Declares/initializes variables. |
if score >= 90 { | Conditional branch. |
fmt.Println("A") | Outputs text using fmt. |
} else if score >= 75 { | Go line. |
fmt.Println("B") | Outputs text using fmt. |
} else { | Go line. |
fmt.Println("C") | Outputs text using fmt. |
} | Go line. |
} | Go line. |
- 1Control flow powers validation, business rules, and batching work.
- 1Missing edge cases and boundaries.
- 1Test with boundary values and keep conditions readable.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Go Golang Go ConditionsGo Switch
Learn Go Switch with a small example you can edit and run.
switch day {
case 1:
fmt.Println("Mon")
default:
fmt.Println("Other")
}
Edit the Go code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
package main | Declares the package name. |
import "fmt" | Imports packages (like fmt). |
func main() { | Program entry point. |
day := 3 | Declares/initializes variables. |
switch day { | Switch selection. |
case 1: | Go line. |
fmt.Println("Mon") | Outputs text using fmt. |
case 2: | Go line. |
fmt.Println("Tue") | Outputs text using fmt. |
case 3: | Go line. |
fmt.Println("Wed") | Outputs text using fmt. |
default: | Go line. |
- 1Control flow powers validation, business rules, and batching work.
- 1Missing edge cases and boundaries.
- 1Test with boundary values and keep conditions readable.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Go Golang Go SwitchGo Loops
Learn Go Loops with a small example you can edit and run.
for i := 1; i <= 3; i++ {
fmt.Println(i)
}
Edit the Go code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
package main | Declares the package name. |
import "fmt" | Imports packages (like fmt). |
func main() { | Program entry point. |
for i := 1; i <= 6; i++ { | Declares/initializes variables. |
if i == 3 { | Conditional branch. |
continue | Go line. |
} | Go line. |
if i == 5 { | Conditional branch. |
break | Go line. |
} | Go line. |
fmt.Println(i) | Outputs text using fmt. |
} | Go line. |
- 1Control flow powers validation, business rules, and batching work.
- 1Missing edge cases and boundaries.
- 1Test with boundary values and keep conditions readable.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Go Golang Go LoopsGo Functions
Learn Go Functions with a small example you can edit and run.
func add(a, b int) int { return a + b }
Edit the Go code below and click Run. The output panel shows the extracted Expected Output notes (or simple prints).
// Expected Output: line so the output panel has something to show.| Line | Meaning |
|---|---|
package main | Declares the package name. |
import "fmt" | Imports packages (like fmt). |
func add(a, b int) int { return a + b } | Declares a function. |
func main() { | Program entry point. |
fmt.Println(add(4, 6)) | Outputs text using fmt. |
} | Go line. |
- 1Functions help you reuse logic and keep code DRY.
- 1Too many parameters and unclear names.
- 1Use clear names and small, focused functions.
- 1Edit the example and rerun to learn faster.
- 2Prefer clarity first; optimize later.
- 1Change one value and predict the output.
- 2Add one edge case and handle it.
- 3Explain the rule in 1 sentence.
Keywords (topic intent):
Go Golang Go Functions