Skip to content
tezvyn:

Go & Rust

Go web services, Rust backends, systems programming

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

Everything in Go & Rust, page 2

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.

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…

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…

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.

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

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.

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.

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.

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.

advanced1 min read

Zero-copy string to []byte conversion via unsafe in Go

Use unsafe.StringData/Slice (or reflect headers) to alias the string's bytes without copying; assumes shared backing array; risk is mutating an immutable string.

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.

advanced1 min read

Profiling a Rust hot loop with perf

Build with debuginfo, perf record cycles or cache-misses, perf report then perf annotate to map counters to source/asm; flamegraph for hotspots.

advanced1 min read

Diagnosing Go memory leaks with pprof heap profiles

Expose net/http/pprof, grab /debug/pprof/heap, analyze inuse_space for live retention versus alloc_space for cumulative allocation; rising inuse over time points to a leak.

advanced1 min read

Cancellation: Go context vs Rust sync stdlib

Go's context.Context threads a Done channel and deadline through call chains; Rust std has no built-in cancellation, so you wire an AtomicBool or channel and check it.

advanced1 min read

Network read/write timeouts in Go vs Rust stdlib

Go uses SetReadDeadline/SetWriteDeadline as absolute times; Rust uses set_read_timeout/set_write_timeout as durations on TcpStream.

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

advanced1 min read

Purpose and mechanism of a Rust build.rs script

Build.rs compiles and runs before the crate, emitting cargo: directives via stdout to set link flags, env vars, and rerun triggers; used to compile C, generate code, or probe the system.

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.

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