What does this loop print?
for _, r := range "abc" {
fmt.Printf("%c ", r)
}
// output?Read the full question →Go is built for concurrent network services. The runtime is small enough that interviews expect you to know how it behaves.
Goroutine leaks, channel and select semantics, nil interface versus nil pointer, escape analysis, context cancellation, and the garbage collector's pacing.
Where it shows up: Cloud infrastructure, platform teams, CLI tooling, and high-throughput API services.
Twenty real Go questions from the library, code snippet included. Nothing here is paraphrased for search engines. It is the same text a signed-in user sees.
for _, r := range "abc" {
fmt.Printf("%c ", r)
}
// output?Read the full question →package mypkg
var Total int
var count intRead the full question →var mu sync.RWMutex
var data = map[string]int{"x": 1}
func read() int {
mu.RLock()
v := data["x"]
mu.Unlock()
return v
}Read the full question →var wg sync.WaitGroup
wg.Add(1)
go func() {
wg.Done()
wg.Done()
}()
wg.Wait()
fmt.Println("done")Read the full question →var wg sync.WaitGroup
for i := 0; i < 5; i++ {
go func() {
wg.Add(1)
defer wg.Done()
work()
}()
}
wg.Wait()Read the full question →func Zeros[T any](n int) []T {
return make([]T, n)
}
func main() {
xs := Zeros(3)
_ = xs
}Read the full question →f, _ := os.Create("cpu.prof")
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()Read the full question →import _ "net/http/pprof"Read the full question →jobs := make(chan int, 100)
var wg sync.WaitGroup
for w := 0; w < 3; w++ {
wg.Add(1)
go func() {
defer wg.Done()
for j := range jobs {
process(j)
}
}()
}
for _, j := range work {
jobs <- j
}
close(jobs)
wg.Wait()Read the full question →t := reflect.TypeOf(s)
f := t.Field(0)
tag := f.Tag.Get("json")Read the full question →func newInt() *int {
x := 42
return &x
}Read the full question →var x any = 7Read the full question →type User struct {
Name string `json:"name"`
}Read the full question →type Animal struct{}
func (Animal) Greet() string { return "Hi from Animal" }
type Dog struct{ Animal }
func (Dog) Greet() string { return "Hi from Dog" }
func main() {
d := Dog{}
fmt.Println(d.Greet())
}Read the full question →type Config struct {
Name string
Retries int
Active bool
}
var c Config
fmt.Printf("%q %d %t", c.Name, c.Retries, c.Active)Read the full question →var a int
c := make(chan struct{})
go func() {
a = 1
c <- struct{}{}
}()
<-c
print(a)Read the full question →v, ok := <-chRead the full question →type User struct {
Name string `json:"full_name"`
}
b, _ := json.Marshal(User{Name: "Ada"})
fmt.Println(string(b))Read the full question →m := map[string]int{"x": 1}
delete(m, "y")
fmt.Println(len(m))Read the full question →package main
func main() {
p := new(int)
_ = p
}Read the full question →We keep the correct answer, the explanation and the scoring behind sign-in so the platform stays honest, which is why the answer options and the worked explanation for every Go question stay behind a free account. Signing in is free and takes a few seconds.
60 distinct Go topics are tagged across the library. These are the real topic labels stored on the questions, not a hand-written list.
…