tezvyn:

Go & Rust

Go web services, Rust backends, systems programming

7 bites

Go & Rust31 sec 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.

Go & Rust30 sec read

Why does Go forbid circular dependencies, and how do you resolve them?

WHAT IT TESTS: Knowledge of Go's DAG package model. ANSWER OUTLINE: Cycles break incremental compilation; resolve by moving logic down, merging coupled packages, or using dependency injection. RED FLAG: Suggesting compiler workarounds over fixing design.

Go & Rust30 sec read

Compare Go's GC and Rust's ownership across performance, productivity, and safety

This tests memory-model trade-offs. Contrast Rust's compile-time ownership for deterministic, zero-cost safety against Go's GC, which optimizes simplicity and onboarding but adds runtime overhead. Red flag: calling one strictly superior.

Go & Rust30 sec read

Go's Worker Pool Pattern: Capping Concurrency

A worker pool caps concurrency by using a fixed number of goroutines to process jobs from a queue. Use it for rate-limiting API calls or processing files without spawning unlimited goroutines.

Go & Rust30 sec read

Go Cobra: Build Complex CLIs Like `kubectl`

Cobra gives your Go CLI a command tree, like `git remote add`. It's for apps with nested commands and persistent flags, not just simple tools. The footgun is using it for a single command when Go's `flag` package would suffice.

Go & Rust31 sec read

Buffered I/O: Batch System Calls for Speed

Buffered I/O batches many small reads or writes into fewer, larger system calls, trading a small amount of memory for a huge speed boost. It's essential for tasks like writing log files line-by-line, preventing a system call for every single line.

Go & Rust30 sec read

Go vs. Rust: Why String Indexing Is Tricky

Rust prevents direct string indexing to force correctness, while Go treats strings as raw byte slices. This matters for non-ASCII text where characters span multiple bytes. The footgun: Go's `s[i]` can corrupt data; Rust's `&s[..i]` can panic.

Go & Rust · Tezvyn