Choose TypeScript, Go, Rust or C++ and find syntax, everyday APIs, standard libraries and tools in one place.
Scope and conventions
TypeScript/Node, Go 1.23+, Rust 2024 and C++23: from a first CLI to files, JSON, HTTP, concurrency and testing. Complete programs are labeled; other examples identify their surrounding code/imports. Optional libraries and version requirements are named in each entry.
var distinguishes absence and non-Unicode environment data. Parse the actual value rather than silently substituting a default for every error.
Fragment
The enclosing function returns Result<_, Box<dyn std::error::Error>>. Port 0 is deliberately excluded here; it has a separate OS-assigned-port meaning.
src/main.rs
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
let raw = match std::env::var("PORT") { Ok(value) => value, Err(std::env::VarError::NotPresent) => "3000".to_owned(), Err(error) => return Err(error.into()),};let port: u16 = raw.parse()?;if port == 0 { return Err("PORT must be 1..65535".into()); }
Command accepts separate arguments and returns status/stdout/stderr. Success in spawning/waiting is distinct from a successful exit status.
Fragment
The enclosing function returns a compatible Result; git must be installed. std::process::Command does not provide a built-in timeout. output buffers both streams.
cargo build uses the development profile; --release selects a separate profile/output. cargo run builds and runs the chosen target. Cargo.toml names the package; executable names may be configured separately.
Fragment
Shell commands; Cargo binary package named app with src/main.rs. Pilot binary: preview.
src/main.rs
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
cargo build./target/debug/app# Build and run current target:cargo run