All questions
Showing of 68What is Go and what are its main characteristics?
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:
Last attempt -
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.
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 ↓
How do you declare variables in Go?
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:
Last attempt -
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"
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 ↓
What is the difference between var and := in Go?
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:
Last attempt -
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)
}
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 ↓
What are Go's basic data types?
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:
Last attempt -
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.
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 ↓
How do you create and use constants in Go?
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:
Last attempt -
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
)
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 ↓
What are slices and how do they differ from arrays?
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:
Last attempt -
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.
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 ↓
How do you work with maps in Go?
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:
Last attempt -
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
nilmap 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")
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 ↓
What are structs in Go and how do you use them?
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:
Last attempt -
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
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 ↓
How do pointers work in Go?
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:
Last attempt -
&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")
}
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 ↓
What are functions in Go and how do you define them?
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:
Last attempt -
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
errorlast. - Named return values act as local variables, and a bare
returnsends 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
}
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 ↓
How does error handling work in Go?
What are the control structures in Go?
What is the difference between make and new in Go?
How do you iterate over collections in Go?
What are packages in Go and how do you use them?
What is the init() function in Go?
How do you handle string manipulation in Go?
What are method receivers in Go?
What is type assertion in Go?
How do you work with JSON in Go?
What are zero values in Go?
How do you convert between different types in Go?
What is the defer statement in Go?
What are variadic functions in Go?
How do you handle command-line arguments in Go?
How do you work with time and dates in Go?
How do you handle file I/O in Go?
How do panic and recover work in Go?
What are interfaces in Go and how do they work?
What are goroutines and how do they work?
Explain channels in Go and their types.
What is the difference between buffered and unbuffered channels?
How do you implement HTTP servers in Go?
How do you handle HTTP middleware in Go?
How do you work with databases in Go?
What is the context package and how do you use it?
How do you implement graceful shutdown in Go HTTP servers?
What are Go modules and how does dependency management work?
How do you write unit tests in Go?
What is the sync package and when do you use it?
How do you handle race conditions in Go?
What are worker pools and how do you implement them?
How do you implement custom error types in Go?
How do Go generics work and when should you use them?
What is reflection in Go and when should you use it?
What are Go build tags and how do you use them?
How do you implement configuration management in Go?
How do you implement logging in Go applications?
What are embedding and composition in Go?
How do you implement pagination in Go APIs?
How do you handle request validation in Go?
How do you implement rate limiting in Go?
Why is an interface holding a nil pointer not equal to nil in Go?
How does append work on Go slices, and when do slices share memory?
How do you handle dependency injection in Go?
How does Go's garbage collector work and how can you optimize for it?
Explain Go's memory model and happens-before relationships.
How would you build a priority job scheduler with a worker pool in Go?
How do you implement distributed locks in Go?
How do you implement efficient caching strategies in Go?
How do you implement event sourcing and CQRS patterns in Go?
How do you profile and optimize the performance of a Go application?
How do you implement microservices communication patterns in Go?
What security practices do you apply when building a Go web API?
How do you implement distributed tracing in Go applications?
How do you debug and inspect a running Go service?
How do you implement custom memory allocators and unsafe optimizations?
How does Go handle metaprogramming, and how do you use go generate?
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
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.
Golang cheatsheet
- Variables & types01
- Slices, maps & loops02
- Functions, defer & errors03
- Structs & interfaces04
- Goroutines, channels & locks05
- HTTP servers & APIs06
- JSON, files & databases07
- Modules, tests & builds08
- Profiling, GC & unsafe09
- Distributed services10
- The model11
- + 5 more inside
This picture is part of Pro. The first chapter is free to play; the other 30 pictures come with Pro.
Get Pro · $10/mo Already Pro? Sign in58 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.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsDjango
Python Full-Stack DevelopmentRuby on Rails
Convention over ConfigurationServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQInterviewers also test these - they're common to every stack, whichever one you picked above.
FastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDInterviewers also test these - they're common to every stack, whichever one you picked above.
AI Engineer
LLMs, RAG, Agents, EvalsAI-Powered Developer
Claude Code, Copilot, Agentic WorkflowsCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.