Skip to content
tezvyn:

Go & Rust

Go web services, Rust backends, systems programming

132 bites

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

Interview questions in Go & Rust, page 6

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.

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

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.

advanced2 min read

Building a safe Rust wrapper over an unsafe C API

Hide extern calls behind a safe module, own the resource in a struct with Drop calling the C free, return Result mapping C error codes, use NewType/NonNull and PhantomData.

advanced1 min read

cgo directives: CFLAGS, LDFLAGS, and pkg-config

#cgo CFLAGS feeds the C compiler include paths/defines, LDFLAGS feeds the linker libraries/paths, pkg-config auto-discovers both; needed to compile against a system C library.

easy1 min read

Structuring a Go CLI that fetches a URL

Parse args with the flag package, http.Get the URL, check err and status, defer resp.Body.Close, copy body to stdout, exit non-zero on failure.

easy2 min read

Handling Result and errors in a Rust web handler

Handler returns Result, the ? operator early-returns errors, a custom error type implements IntoResponse to map to 500, success returns 200 with data.

easy1 min read

In-memory rate limiter middleware in Go

Use a token-bucket limiter (golang.org/x/time/rate), guard a per-client map with sync.Mutex, wrap http.Handler so requests over the limit get 429.

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

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>.

intermediate2 min read

Using context.Context across microservice calls in Go

Context carries cancellation, deadlines, and values; pass ctx as first arg, set one WithTimeout at the edge, attach a request ID via WithValue, thread it through downstream calls so all cancel…

intermediate1 min read

Rust Send and Sync marker traits explained

Send means a value can move across threads, Sync means a reference can be shared; Rc uses non-atomic refcounts, Arc uses atomic ones.

advanced1 min read

Architecting an L7 proxy in Go versus Rust

Go offers GC and cheap goroutines for fast delivery but tail-latency GC pauses; Rust offers ownership and async/await for predictable latency at higher complexity.

advanced2 min read

Why Pin is needed for self-referential Futures

Async blocks compile to state machines that can hold references into their own storage; Pin guarantees the value will not move so those internal pointers stay valid across polls.

intermediate1 min read

Fearless concurrency: Rust compile-time vs Go runtime

Rust uses ownership plus Send/Sync to reject data races at compile time; Go encourages channels but still allows races, with the runtime race detector catching them at test…

intermediate2 min read

Rust lifetimes versus Go garbage-collected lifetimes

A lifetime is a compile-time region a reference is valid for; annotations like 'a relate input and output reference durations; Go instead uses garbage collection and escape analysis.

intermediate1 min read

Criterion: the standard Rust benchmarking library

Criterion runs on stable Rust, collects many samples, applies statistical analysis with confidence intervals, and compares against saved baselines to detect regressions.

intermediate1 min read

Structural Go interfaces versus nominal Rust traits

Go interfaces are satisfied implicitly by method shape (structural); Rust traits must be explicitly implemented (nominal).

intermediate1 min read

Goroutines and channels versus ownership-based concurrency

Go uses cheap goroutines and CSP-style channels to coordinate by communication; Rust uses ownership plus Send/Sync to make data races a compile error.

intermediate2 min read

Go (T, error) versus Rust Result for error handling

Go returns a separate error value you may ignore; Rust wraps success or error in one Result enum the compiler forces you to handle. Go favors simplicity, Rust favors compile-enforced safety.

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