All bites
The whole library, newest first. Filter by what you are here for, or pick a topic if you already know.
8668 bites
Page 161
What Go tool detects data races and how do you invoke it?
This tests Go's built-in race detector. A strong answer names the -race flag, notes it instruments memory accesses to catch concurrent unsynchronized reads/writes, and shows go test -race. A red flag is confusing it with static analysis or external tools.
What is the difference between Cargo.toml and Cargo.lock?
Cargo.toml declares broad requirements; Cargo.lock pins exact resolved versions.
How do you initialize and manage Go dependencies?
Init with go mod init; use go get and go mod tidy; go.mod sets path and versions, go.sum stores checksums for verified builds.
When should Rust atomics replace a Mutex, and how do orderings work?
Atomics replace mutexes for counters; Relaxed is atomicity only, SeqCst adds global order, weaker ones skip fences on ARM.
Go select vs Rust select! fairness and determinism
This tests runtime fairness in concurrent primitives. Contrast Go's pseudo-random case selection with Tokio's randomized default and its opt-in biased; top-down mode. Red flag: claiming Go uses source order or that Rust randomization is unavoidable.
What is Go's context package and how do you use WithCancel?
This tests cancellation propagation. A good answer says Context carries deadlines, signals; derive a child with WithCancel, pass it to worker, then call cancel to unblock ctx.Done. Bad: storing context in structs, leaking cancel functions, or ignoring Done.
Buffered vs unbuffered Go channels and deadlock scenario
Tests channel synchronization semantics. Unbuffered channels block until sender and receiver rendezvous; buffered channels block only when full or empty. Deadlock: goroutine sends on unbuffered channel with no receiver.
How do Send and Sync prevent data races? Give a Send-but-not-Sync example.
Explain Send moves values and Sync allows shared references across threads; give Cell as Send but not Sync because it has interior mutability.
What is the fundamental difference between a goroutine and an OS thread?
This tests your grasp of Go's M:N scheduler. A strong answer notes that goroutines are runtime-managed, multiplexed onto OS threads, and use far less memory per unit, enabling thousands of concurrent tasks.
Describe Rust's orphan rule and its ecosystem purpose
State that either trait or type must be local; explain this stops conflicting foreign impls; note crates.io would see silent impl collisions breaking downstream builds.
Static dispatch with impl Trait versus dynamic dispatch with Box<dyn Trait>
Tests monomorphization versus vtables. Note: static dispatch monomorphizes for zero-cost abstraction but bloats code; dynamic dispatch uses vtables for smaller binaries but adds indirection.
Explain Go's empty interface, safe usage, and runtime risks
Interface{} (alias any) holds values; unpack with type switches or ok assertions; risks are panics from bare assertions and nil interface vs nil concrete value confusion.
What is the difference between defining a Rust trait and implementing it?
Define with trait and signatures; implement with impl Trait for Type and concrete bodies.
How does a Go type satisfy an interface? Provide an io.Reader example.
This tests implicit structural typing in Go. A type satisfies an interface by implementing every required method with exact signatures; no declaration links them. A red flag is claiming you need an implements keyword or explicit conformance.
Design a custom Go error type with context, Is, As, and Unwrap
This tests Go 1.13 error wrapping and Unwrap conventions. Answer: struct with Err and context fields; implement Error and Unwrap; note errors.Is and errors.As walk the chain. Red flag: stringifying the error via fmt.Errorf %v, which severs unwrapping.
How does the question mark operator use From to unify error types?
This tests Rust error conversion mechanics. You define a unified enum error and implement From for each source error so ? automatically converts via From::from. A red flag is suggesting manual match or map_err on every call instead of trait-based conversion.
What is the difference between unwrap and expect on Option and Result?
It tests your Rust error-handling discipline and justified panics. Both extract values or panic, but expect adds a custom message. Use them only for unrecoverable invariant violations, not routine errors. A red flag is using them as lazy error propagation.
Difference between errors.Is and errors.As in Go
This tests error-chain inspection in Go. errors.Is checks sentinel equality through wrapping, such as os.ErrNotExist. errors.As extracts a custom type, like os.PathError, into a variable. A red flag is using direct == or type assertions on wrapped errors.
Rust's operator equivalent to Go's if err != nil return err
Tests if you know Rust's ? operator for error propagation. A strong answer names ?, explains it returns Err from the function via Result's Try and FromResidual traits, and unwraps Ok. Red flag: calling it .unwrap() or suggesting manual match is idiomatic.
What are Rust Result's variants and how does the compiler enforce handling?
This tests Rust's explicit error model. A strong answer names Ok(T) and Err(E), explains must_use warns when Results are ignored, and notes pattern matching or ? is required to extract values.