Skip to content
tezvyn:

Go & Rust

Go web services, Rust backends, systems programming

74 bites

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

Easy everything in Go & Rust, page 3

easy2 min read

Rust's `libc` Crate: Speaking the OS's Language

The libc crate is Rust's dictionary for C types, letting you talk to the OS. Use it for system calls or linking C libraries, like when building low-level network tools.

easy2 min read

Rust's `extern` Block: Talking to Other Languages

An extern block is Rust's contract for calling code from other languages, like C. You declare external functions and statics, promising they exist. Use it for FFI to call system libraries, but know all calls are unsafe as Rust can't verify them.

easy2 min read

Go Linker Flags: Injecting Data at Build Time

Go's -ldflags lets you inject data into your program at build time. This is perfect for embedding version numbers or git commit hashes into variables without hardcoding them. The main footgun is that the target variable must be a top-level string.

easy2 min read

Rust `cfg`: Compile Code for Specific Targets

Rust's cfg attribute acts like a compile-time switch, including or excluding code based on the target platform or features. It's used for cross-platform support (e.g., Windows vs. Unix) or enabling optional dependencies.

easy2 min read

Go Test Coverage: Rewriting Source to See What's Untested

Go's coverage tool rewrites your source code, adding counters to see what's executed during tests. It's a powerful way to find untested code, but remember: high coverage doesn't guarantee your tests are actually checking for correctness.

easy2 min read

Rust Doctests

Rust doctests are code examples written inside documentation comments that the compiler extracts, compiles and runs as real tests, so your documentation's example code is guaranteed to keep working instead of silently rotting out of date.

easy2 min read

Rust Unit Tests: Co-locating Tests with Code

In Rust, unit tests live inside a special tests module within the same file as the code they're testing. This lets you test a module in isolation, including its private functions.

easy2 min read

Go Table-Driven Tests: Test More with Less Code

Instead of copy-pasting tests, define inputs and expected outputs in a table (a slice or map) and loop through them. This is the idiomatic Go way to test functions with many edge cases. The main footgun is a closure bug in parallel tests; re-shadow the.

Go vs. Rust: Why String Indexing Is Tricky
easy2 min 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.

easy2 min read

Go's Time: Wall Clocks vs. Monotonic Clocks

Go separates telling time (wall clock) from measuring it (monotonic clock) to prevent errors from system clock changes. Use time.Sub for reliable timing and time.Format for display. The footgun: formatting uses a magic date, not YYYY-MM-DD.

easy2 min read

Go-Style vs. GNU-Style Flag Parsing

Go's command-line parser is stricter than the familiar GNU style, not distinguishing short/long flags or allowing them after arguments. This is key when porting Go CLIs to Rust to maintain user experience.

easy2 min read

Go's `os` Package: Your File System Toolkit

Go's os package is your universal remote for the file system. Use ReadFile for quick access or open a File object for finer control. It's essential for logs and configs. Forgetting to Close() a file leaks resources and can crash your program.

easy2 min read

cargo test: Rust's All-in-One Test Runner

cargo test is Rust's built-in test runner, automatically discovering and executing unit, integration, and documentation tests. Use it to validate code marked with #[test] and examples in docs.

easy2 min read

cargo build: Compile Your Rust Package and Its Dependencies

Think of cargo build as your project's general contractor. It reads the Cargo.toml blueprint to compile your package and all its dependencies. A common footgun is forgetting it only builds libraries and binaries by default; use --tests for test targets.

easy2 min read

Go Build: From Source Code to Executable

go build is your factory for turning Go source into a runnable program. It compiles your packages and their dependencies into a single executable. Use it to create a binary for deployment, but don't confuse it with go install which puts the file in your.

easy2 min read

Rust Channels: Thread-Safe Communication

Rust channels are like a thread-safe conveyor belt for sending data between threads. Use them to pass work to workers or aggregate results. The footgun: the receiver blocks forever if any sender isn't dropped, as the channel only closes when all senders are…

easy2 min read

Rust's std::thread::spawn: Create and Manage OS Threads

std::thread::spawn creates a new OS thread to run code concurrently, returning a JoinHandle to wait for completion. Use it for background tasks or parallel computations. The footgun: dropping the handle detaches the thread, risking resource leaks.

easy2 min read

Handling Errors with Rust's Result Enum

Rust's Result enum makes error handling explicit. Instead of returning a value that might be an error code, functions return either Ok(value) or Err(error). It's used for recoverable failures like I/O.

easy2 min read

Rust's Option<T>: Handling Absence Safely

Rust's Option<T> is a type-safe box that holds either a value (Some(T)) or nothing (None), eliminating null pointer errors. Use it for function returns that might fail or for optional struct fields. The footgun is .unwrap(), which panics on None.

easy2 min read

Go's `error` Interface: Errors Are Values

In Go, an error is any value that can describe its own failure string. Functions like os.Open return an error to signal problems. The footgun is only checking for nil and ignoring the rich, structured data a custom error type can provide.

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