tezvyn:

Go & Rust

Go web services, Rust backends, systems programming

276 bites

Go & Rust2 min read

What are Rust's two macro categories and use cases?

WHAT IT TESTS: Whether you know Rust's declarative versus procedural macro distinction. ANSWER OUTLINE: Name macro_rules! for syntax like vec!, and procedural macros for custom derive on structs. RED FLAG: Calling them C-style substitution or runtime code.

Go & Rust2 min read

What is go generate and how does it differ from make?

This tests whether go generate is a pre-build code generator, not a build system. Strong answers cover //go:generate directives, no dependency analysis, and committing generated files. A red flag is calling it a make replacement or an automatic build step.

Go & Rust2 min read

Compare Go and Rust approaches to exposing profiling data

WHAT IT TESTS: Trade-offs between Go's pull model and Rust's push or attach models. ANSWER OUTLINE: Contrast Go's pprof import with Rust crates or profilers, noting runtime versus OS-level sampling. RED FLAG: Claiming Rust has a std-lib pull endpoint like Go.

Go & Rust2 min read

Explain fuzz testing and set up a basic fuzz test

This tests coverage-guided fuzzing and toolchain wiring. Strong answer: defines fuzzing as automated input mutation driven by code coverage, contrasts it with hand-written examples, and sketches Go's FuzzXxx or Rust's cargo-fuzz setup.

Go & Rust2 min read

Generate a Go CPU profile and visualize it as a flame graph

This tests Go profiling workflow and flame graph literacy. A good answer covers net/http/pprof setup, go tool pprof collection, flame graph generation, and reading width as cumulative CPU time and height as call depth. Red flag: width means call count.

Go & Rust2 min read

How do you use ResetTimer, StopTimer, and RunParallel in Go benchmarks?

Tests Go benchmark timer hygiene and parallel execution. A strong answer covers b.StopTimer before setup, b.ResetTimer before the loop, and b.RunParallel for CPU-bound scaling. A red flag is resetting without stopping or using parallel benchmarks for I/O.

Go & Rust2 min read

What is go test -race and when is it crucial?

This tests knowledge of Go's race detector. A strong answer says -race instruments code to detect racy reads/writes, finds data races not deadlocks, and is crucial for concurrent apps under load.

Go & Rust2 min read

How does Rust differentiate unit and integration tests?

Tests Rust test layout and privacy. Unit tests sit in src/ under #[cfg(test)] and call private functions via super::. Integration tests go in tests/ as external crates. Wrong: claiming it blocks private testing or merging them into src/.

Go & Rust2 min read

How do you write a table-driven test in Go?

Tests idiomatic Go test design. A strong answer: slice/map of structs with inputs/expected outputs, loop with t.Run for named subtests, and cite DRY code, parallelization, and failure isolation. Red flag: separate Test functions per case or omitting t.Run.

Go & Rust2 min read

Compare Go's []byte and Rust's &[u8]

Tests memory-model depth: Go slices are GC-managed headers (ptr, len, cap) permitting shared mutation, while Rust &[u8] is a borrow-checked fat pointer (ptr, len) enforcing aliasing-XOR-mutation.

Go & Rust2 min read

Compare Go's error tuples to Rust's Result for I/O

Tests trade-offs between Go's explicit error returns and Rust's Result type. Contrast Go's inline err checks with Rust's ? operator, noting verbosity versus compile-time exhaustiveness. Never call Result an exception or claim Go ignores errors.

Go & Rust2 min read

Compare efficient line-by-line file reading in Go and Rust

TESTS: Memory-efficient streaming I/O idioms. OUTLINE: Go uses bufio.Scanner with ScanLines/Scan(); Rust uses BufReader with lines() or read_line(). RED FLAG: Loading the whole file with ioutil.ReadFile or fs::read_to_string.

Go & Rust2 min read

Serialize a Go struct to JSON and contrast with Rust

This tests fluency in Go's encoding/json versus Rust's derive macro ecosystem. Go: call json.Marshal on exported fields; Rust: derive Serialize, then serde_json::to_string. Red flag: claiming Rust uses std-only serialization or that Go needs external crates.

Go & Rust2 min read

Build a TCP server in Go and Rust using standard libraries

Tests standard-library networking APIs in both languages. Strong answer: Go's net.Listen with Accept loop vs Rust's std::net::TcpListener::bind and incoming iterator. Red flag: reaching for HTTP or async frameworks instead of core TCP primitives.

Go & Rust2 min read

Read a file into a byte slice in Go and Rust

This tests standard-library convenience APIs for slurping files. In Go, use os.ReadFile (1.16+) returning ([]byte, error). In Rust, use std::fs::read returning Result<Vec<u8>>. A red flag is opening a file and looping over reads when a one-liner exists.

Go & Rust2 min read

What does go mod tidy do beyond adding dependencies?

Tests reproducible Go module graph knowledge. A strong answer covers that tidy reconciles imports with go.mod, prunes unused modules, and ensures go.sum contains every checksum for the minimal build list.

Go & Rust2 min read

How do you manage multiple related Rust crates as a single unit?

Tests Cargo workspaces for multi-crate Rust projects. Strong answers cite the [workspace] section, shared Cargo.lock, unified target directory, inherited metadata, and workspace-wide commands.

Go & Rust2 min read

Explain Cargo features and how to define and enable them

This tests conditional compilation and optional dependency design in Rust. A strong answer outlines the [features] table, cfg attribute gating, and consumer enablement via --features or default features.

Go & Rust2 min read

Difference between go build and go install? Cross-compile for ARM64 Linux?

Tests Go toolchain artifact placement and native cross-compilation. A strong answer distinguishes go build (current directory) from go install ($GOBIN), then sets GOOS=linux GOARCH=arm64 for cross-compilation.

Go & Rust2 min read

How does cargo differentiate unit and integration tests by location?

This tests Rust test layout conventions. Unit tests live inside src files in cfg(test) modules; integration tests go in top-level tests/ files as separate crates. Red flag: saying integration tests need cfg(test) or can use private APIs.