Easy concepts in Go & Rust, page 2
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.
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.
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.
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.
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.
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.

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

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.
Rust's `clap`: Build CLIs by Describing Them
clap lets you define a Rust struct representing your CLI's arguments, and it generates the parser, help text, and validation. It's used for building any Rust CLI, but its feature-richness can increase binary size over simpler alternatives.
The Builder Pattern: Constructing Complex Objects in Rust
The Builder pattern lets you construct complex objects step-by-step using a chain of method calls. It's crucial in Rust for structs with many optional fields, since the language lacks default arguments.
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