Skip to content
tezvyn:

Go & Rust

Go web services, Rust backends, systems programming

133 bites

Test yourself: Top 30 intermediate Go & Rust interview questionsMultiple choice, with the correct answer and why it is correct on every question. Free, no sign-in.

Intermediate everything in Go & Rust, page 2

intermediate2 min read

Static dispatch over Write with generics in Rust

Write generically over the std::io::Write trait with a type parameter W: Write, letting the compiler monomorphize and inline per concrete type, avoiding the vtable indirection of Box<dyn Write>.

intermediate1 min read

Logging middleware wrapping an http.Handler in Go

Middleware has signature func(http.Handler) http.Handler, records start time, calls next.ServeHTTP, then logs method, URL, and elapsed duration; chaining works because the wrapper is itself a…

intermediate2 min read

Passing Go/Rust callbacks to a C library

C needs a plain function pointer; in Go use //export with cgo, in Rust an extern "C" fn; carry state via a void* user-data param.

intermediate1 min read

Rust references vs raw pointers

References are borrow-checked, always valid, aliasing-controlled, non-null; raw pointers carry no guarantees, can be null, dangling, or aliased, and dereferencing needs unsafe.

intermediate1 min read

Concurrent TCP server: Go goroutines vs Rust std::thread

Both accept in a loop; Go spawns a goroutine per connection (go handle(conn)); Rust spawns an OS thread (thread::spawn moving the stream).

intermediate1 min read

Rust async/await vs Go goroutines

Go schedules goroutines on a built-in runtime transparently; Rust futures are inert until polled by an external runtime like Tokio, and async colors functions.

intermediate1 min read

Sharing mutable state: Go mutex vs Rust Arc Mutex

Go uses sync.Mutex by convention; Rust wraps data in Arc<Mutex<T>> so locking is mandatory, enforced by Send/Sync and the borrow checker.

intermediate1 min read

Value versus pointer receivers and interface satisfaction

Value-receiver methods belong to both T and *T, but pointer-receiver methods belong only to *T, so a value of T may not satisfy an interface.

intermediate2 min read

Rust borrow rules versus Go race prevention

Rust's aliasing-XOR-mutability rule plus Send and Sync make races a compile error; Go prevents them at runtime via channels, mutexes and the race detector.

intermediate1 min read

Rust binary and library crates in one project

A binary crate has main and produces an executable; a library crate has lib.rs and is reusable; put logic in the lib and a thin main that calls it.

Explain the performance overhead of a cgo call
intermediate2 min read

Explain the performance overhead of a cgo call

Tests cgo transition penalties and scheduler semantics. A strong answer cites the ~100x overhead (~171ns vs ~1.8ns), notes C blocks an OS thread and starves the scheduler, and warns about memory copy taxes. Red flag: claiming cgo is free or ignoring blocking.

intermediate2 min read

Why must FFI-bound structs use #[repr(C)] and what breaks without it?

Repr(C) fixes field order, size, alignment to C rules for extern calls; omitting it lets Rust reorder or pad fields, causing UB.

Use a C malloc'd char* in Go and Rust, then free it
intermediate2 min read

Use a C malloc'd char* in Go and Rust, then free it

Tests FFI allocator discipline. In Go, copy with C.GoString then C.free the *C.char. In Rust, read via CStr::from_ptr, copy to String, then libc::free. Red flag: letting Go GC or Rust Drop manage C memory, or using CString::from_raw on C malloc'd pointers.

intermediate2 min read

What are Rust's three procedural macros and derive's advantage over macro_rules?

Tests Rust macros and AST generation vs text macros. Lists derive, attribute-like, and function-like macros, then explains derive needs AST introspection for per-field impl unreachable with macro_rules. Red flag: that macro_rules can iterate struct fields.

intermediate2 min read

In Go's reflect package, what is settability and how is it obtained?

This tests whether you know reflection mutates only addressable storage. Settability means a Value points to actual memory; obtain it by calling reflect.ValueOf on a pointer then Elem, or on slice elements. Set panics when the Value is a copy, not an address.

intermediate2 min read

Using reflect, iterate a pointer-to-struct's fields

Tests fluency with Go reflection for indirection and field traversal. Outline: ValueOf/TypeOf, guard IsValid, check Kind==Ptr, Elem to struct, loop NumField with Type for names and Value for values. Red flag: Field() on the pointer before Elem panics.

intermediate2 min read

Explain fuzz testing and set up a basic fuzz test

This tests coverage-guided fuzzing and toolchain wiring. Strong answer: defines fuzzing as automated input mutation driven by code coverage, contrasts it with hand-written examples, and sketches Go's FuzzXxx or Rust's cargo-fuzz setup.

intermediate2 min read

Generate a Go CPU profile and visualize it as a flame graph

This tests Go profiling workflow and flame graph literacy. A good answer covers net/http/pprof setup, go tool pprof collection, flame graph generation, and reading width as cumulative CPU time and height as call depth. Red flag: width means call count.

intermediate2 min read

How do you use ResetTimer, StopTimer, and RunParallel in Go benchmarks?

Tests Go benchmark timer hygiene and parallel execution. A strong answer covers b.StopTimer before setup, b.ResetTimer before the loop, and b.RunParallel for CPU-bound scaling. A red flag is resetting without stopping or using parallel benchmarks for I/O.

intermediate2 min read

Compare Go's []byte and Rust's &[u8]

Tests memory-model depth: Go slices are GC-managed headers (ptr, len, cap) permitting shared mutation, while Rust &[u8] is a borrow-checked fat pointer (ptr, len) enforcing aliasing-XOR-mutation.

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles