Everything in Go & Rust, page 2
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.
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…
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>.
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…
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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.
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.
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