Skip to content
Learn Netverks

Lesson

Step 15/36 42% through track

pointers-go

Pointers

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

This lesson

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

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

You will apply Pointers 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).

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

Pointers hold memory addresses: *T points to T, &x takes address, *p dereferences. Go has pointers but no pointer arithmetic—safer than C, simpler than Rust lifetimes for most code.

When pointers matter

  • Mutate function arguments
  • Avoid copying large structs
  • Share mutable state (carefully—prefer channels for concurrency)
  • Represent optional or nullable values before generics

new vs composite literals

new(T) allocates zero value and returns *T. Often &T{...} is clearer for structs with initial fields.

Important interview questions and answers

  1. Q: Pointer arithmetic?
    A: Not allowed in Go—unlike C/C++.
  2. Q: nil pointer?
    A: Zero value of pointers is nil; dereferencing nil panics—check before use.

Self-check

  1. What operator gets the address of x?
  2. What happens when you dereference a nil pointer?

Pitfall: Dereferencing nil panics—always guard or initialize pointers before *p access.

Interview prep

Pointer arithmetic?

Not allowed—unlike C/C++.

Nil pointer dereference?

Panics at runtime—check before dereferencing.

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

  • nil pointer?
  • & vs *?

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