LearnThatStack Ace your next interview
Backend Development

Golang.

Start free Change topic Change
Practice · Questions

All questions

Showing of 68
Beginner 27
01

What is Go and what are its main characteristics?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Go, also called Golang, is an open-source programming language developed by Google. It is statically typed, so the compiler checks types before the program runs. It compiles to native machine code instead of running on a virtual machine. A garbage collector manages memory automatically.

Concurrency is built in through goroutines, which are lightweight threads that the Go runtime schedules for you. The syntax is minimal, with few keywords, and builds are fast. The same program compiles for many operating systems and processor architectures.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

02

How do you declare variables in Go?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Go has two ways to declare a variable: the var keyword and the short form :=. With var you can state the type, let the compiler infer it from the value, or leave the value out. A variable declared without a value starts at its type's zero value.

The short variable declaration name := "John" always needs a value, infers the type from it, and works only inside functions. Both forms can declare several variables on one line. The compiler rejects a local variable that is declared but never used.

// Explicit type declaration
var name string = "John"
var age int = 30

// Type inference
var user = "John"
var score = 30

// Short variable declaration (inside functions only)
nick := "John"
level := 30

// Multiple variable declaration
var a, b, c int = 1, 2, 3
x, y := 10, "hello"
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

03

What is the difference between var and := in Go?

Visual

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
Visual

var is the full declaration and works at package level and inside functions, while :=, the short variable declaration, works only inside functions. With var you can name the type and skip the value, and the variable then holds its zero value. := always needs a value and infers the type from it. At package level you must use var.

Inside a function, := can also redeclare a variable, as long as at least one name on its left is new. Redeclaring assigns to the existing variable. That is why val, err := f() can appear after err already exists.

One trap is := inside an inner block, which creates a new variable that shadows the outer one instead of assigning to it.

// Package level - must use var
var globalVar string

func main() {
    // Both are valid inside functions
    var localVar string    // Zero value: ""
    shortVar := "hello"    // Type inferred as string
    fmt.Println(globalVar, localVar, shortVar)
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

04

What are Go's basic data types?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Go's basic types are booleans, numbers and strings. The numeric types come in several sizes:

  • Signed integers: int, int8, int16, int32, int64
  • Unsigned integers: uint, uint8, uint16, uint32, uint64
  • Floating point: float32, float64
  • Complex numbers: complex64, complex128

Most have a fixed size in their name, but int and uint are either 32 or 64 bits wide, depending on the platform.

A bool holds true or false. A string holds UTF-8 encoded text and cannot change once created. byte is an alias for uint8, used for raw data. rune is an alias for int32 and holds one Unicode code point.

Go never converts numeric types on its own, so mixing int and int64 needs an explicit conversion.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

05

How do you create and use constants in Go?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Declare a constant with the const keyword. Its value is fixed when the program compiles and can never change. You can group related constants in a const ( ... ) block. Inside a group, iota starts at 0 and goes up by one on each line, which makes it the usual way to build enum-like values.

A constant without a stated type is an untyped constant, so it takes the type the context needs. That is why Pi works with both float32 and float64 values. Only values the compiler can work out, such as numbers, strings and booleans, can be constants, so a slice cannot be one.

const Pi = 3.14159
const MaxUsers = 100

// Grouped constants
const (
    StatusOK     = 200
    StatusError  = 500
    StatusPending = 202
)

// iota for auto-incrementing constants
const (
    Sunday = iota  // 0
    Monday         // 1
    Tuesday        // 2
)
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

06

What are slices and how do they differ from arrays?

Visual

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
Visual

A slice is a growable view over an array, while an array has a fixed size. An array's size is part of its type, so [5]int and [6]int are different types. A slice is a small header of three fields: a pointer to the array, a length and a capacity.

Arrays are values, so assigning one copies every element. Assigning a slice copies only its header, so both slices share the same elements.

// Array - fixed size
var arr [5]int = [5]int{1, 2, 3, 4, 5}

// Slice - dynamic size
var slice []int = []int{1, 2, 3, 4, 5}
slice = append(slice, 6) // Can grow

// Creating slices
slice1 := make([]int, 5)      // length 5, capacity 5
slice2 := make([]int, 5, 10)  // length 5, capacity 10

Most Go code uses slices, because they grow with built-in functions like append() and pass cheaply to functions.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

07

How do you work with maps in Go?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

You create a map with make or a map literal, then read and write entries with m[key]. A map is Go's built-in hash table of key-value pairs. Reading a missing key returns the zero value. The comma-ok form v, ok := m[key] tells a missing key from a stored zero. delete removes a key, and len counts the entries.

  • Keys must be comparable types, such as strings, numbers or structs of them.
  • Iteration order is not specified, so never rely on it.
  • A nil map can be read but panics on write, so always create the map first.
  • Maps are not safe for concurrent writes, so guard a shared map with a sync.Mutex.
// Creating maps
ages := make(map[string]int)
ages["Alice"] = 30
ages["Bob"] = 25

// Map literal
ages = map[string]int{
    "Alice": 30,
    "Bob":   25,
}

// Checking if key exists
age, exists := ages["Alice"]
if exists {
    fmt.Println("Alice's age:", age)
}

// Deleting keys
delete(ages, "Bob")
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

08

What are structs in Go and how do you use them?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

A struct is a custom type that groups related data into named fields, with no inheritance. You create one with a composite literal, either by field name or by position in field order. Field names are safer, because adding a field later does not break the code.

Access fields with a dot. Go dereferences a struct pointer for you, so p3.Name works on &Person{...}. Fields you leave out get their zero values. Structs are values, so assigning one copies all of its fields.

type Person struct {
    Name string
    Age  int
    City string
}

// Creating struct instances
p1 := Person{Name: "Alice", Age: 30, City: "NYC"}
p2 := Person{"Bob", 25, "LA"} // positional
p3 := &Person{Name: "Charlie", Age: 35} // pointer to struct

// Accessing fields
fmt.Println(p1.Name)
p1.Age = 31
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

09

How do pointers work in Go?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

&x gives the address of x, and *p reads or writes the value at that address, so changing *p changes x. A pointer is a variable that stores such an address. The type *int means a pointer to an int, and its zero value is nil. Dereferencing a nil pointer panics at run time.

Go uses pass by value for every argument. Pass a pointer when a function must change the caller's variable, or when copying a large struct costs too much. Go has no pointer arithmetic. The garbage collector keeps a value alive while any pointer to it exists, so returning a pointer to a local variable is safe.

var x int = 42
var p *int = &x  // p points to x

fmt.Println(*p)  // Dereference: prints 42
*p = 21          // Change value through pointer
fmt.Println(x)   // prints 21

// Zero value of pointer is nil
var ptr *int
if ptr == nil {
    fmt.Println("Pointer is nil")
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

10

What are functions in Go and how do you define them?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

A function is defined with the func keyword, then its name, its parameters and its result types.

  • Parameters that share a type can share one type name, as in a, b int.
  • A Go function can return multiple values, and the usual pattern returns a result plus an error last.
  • Named return values act as local variables, and a bare return sends back their current values.
  • Functions are also values, so you can pass them as arguments, store them in variables and return them as closures.
func add(a, b int) int {
    return a + b
}

func divide(a, b float64) (float64, error) {
    if b == 0 {
        return 0, errors.New("division by zero")
    }
    return a / b, nil
}
func calculate(a, b int) (sum, product int) {
    sum = a + b
    product = a * b
    return // naked return
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

11

How does error handling work in Go?

Part of Pro Visual
12

What are the control structures in Go?

Part of Pro
13

What is the difference between make and new in Go?

Part of Pro
14

How do you iterate over collections in Go?

Part of Pro
15

What are packages in Go and how do you use them?

Part of Pro
16

What is the init() function in Go?

Part of Pro
17

How do you handle string manipulation in Go?

Part of Pro
18

What are method receivers in Go?

Part of Pro Visual
19

What is type assertion in Go?

Part of Pro
20

How do you work with JSON in Go?

Part of Pro
21

What are zero values in Go?

Part of Pro
22

How do you convert between different types in Go?

Part of Pro
23

What is the defer statement in Go?

Part of Pro Visual
24

What are variadic functions in Go?

Part of Pro
25

How do you handle command-line arguments in Go?

Part of Pro
26

How do you work with time and dates in Go?

Part of Pro
27

How do you handle file I/O in Go?

Part of Pro
Intermediate 28
28

How do panic and recover work in Go?

Part of Pro Visual
29

What are interfaces in Go and how do they work?

Part of Pro
30

What are goroutines and how do they work?

Part of Pro Visual
31

Explain channels in Go and their types.

Part of Pro
32

What is the difference between buffered and unbuffered channels?

Part of Pro Visual
33

How do you implement HTTP servers in Go?

Part of Pro
34

How do you handle HTTP middleware in Go?

Part of Pro Visual
35

How do you work with databases in Go?

Part of Pro
36

What is the context package and how do you use it?

Part of Pro Visual
37

How do you implement graceful shutdown in Go HTTP servers?

Part of Pro Visual
38

What are Go modules and how does dependency management work?

Part of Pro Visual
39

How do you write unit tests in Go?

Part of Pro
40

What is the sync package and when do you use it?

Part of Pro
41

How do you handle race conditions in Go?

Part of Pro Visual
42

What are worker pools and how do you implement them?

Part of Pro Visual
43

How do you implement custom error types in Go?

Part of Pro
44

How do Go generics work and when should you use them?

Part of Pro
45

What is reflection in Go and when should you use it?

Part of Pro
46

What are Go build tags and how do you use them?

Part of Pro
47

How do you implement configuration management in Go?

Part of Pro
48

How do you implement logging in Go applications?

Part of Pro
49

What are embedding and composition in Go?

Part of Pro
50

How do you implement pagination in Go APIs?

Part of Pro Visual
51

How do you handle request validation in Go?

Part of Pro
52

How do you implement rate limiting in Go?

Part of Pro Visual
53

Why is an interface holding a nil pointer not equal to nil in Go?

Part of Pro Visual
54

How does append work on Go slices, and when do slices share memory?

Part of Pro Visual
55

How do you handle dependency injection in Go?

Part of Pro
Expert 13
56

How does Go's garbage collector work and how can you optimize for it?

Part of Pro Visual
57

Explain Go's memory model and happens-before relationships.

Part of Pro Visual
58

How would you build a priority job scheduler with a worker pool in Go?

Part of Pro Visual
59

How do you implement distributed locks in Go?

Part of Pro Visual
60

How do you implement efficient caching strategies in Go?

Part of Pro Visual
61

How do you implement event sourcing and CQRS patterns in Go?

Part of Pro Visual
62

How do you profile and optimize the performance of a Go application?

Part of Pro
63

How do you implement microservices communication patterns in Go?

Part of Pro
64

What security practices do you apply when building a Go web API?

Part of Pro
65

How do you implement distributed tracing in Go applications?

Part of Pro Visual
66

How do you debug and inspect a running Go service?

Part of Pro
67

How do you implement custom memory allocators and unsafe optimizations?

Part of Pro Visual
68

How does Go handle metaprogramming, and how do you use go generate?

Part of Pro

No matches

Try a different filter or search term.

Know someone prepping for Golang? Send them this set.
Quick recap

Golang in pictures.

A quick recap of Golang in 33 short animated pictures, one idea at a time. About 8 min to get the whole topic back in your head before you walk in. Pause any picture, slow it down, or step through it.

Pro The first chapter is free to play. The other 30 pictures come with Pro.

Get Pro · $10/mo
Pro · $10/mo

58 of 68 Golang answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime

Change topic

Pick a different technology or stack. Your current topic stays put until you choose a new one.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

Serverless on AWS

Serverless Architecture on AWS

Flutter Mobile

Flutter Cross-Platform Mobile Development

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

AI Engineer

LLMs, RAG, Agents, Evals

AI-Powered Developer

Claude Code, Copilot, Agentic Workflows

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git