Code Snippets

Category: File I/O

Write a File in Go

Atomically write bytes to disk with os.WriteFile.

Author: chris

Read a File to String in Go

Read an entire file into memory with os.ReadFile.

Author: chris

Iterate a Directory in Rust

Walk a single directory level with std::fs::read_dir.

Author: chris

Write a File in Rust

Persist a string atomically using std::fs::write.

Author: chris

Read a File to String in Rust

Read an entire file into a String using std::fs::read_to_string.

Author: chris

Recursive Glob in Ruby

Find every `.rb` file under a tree with Dir.glob and `**` recursion.

Author: chris

Read a File into a String

Slurp an entire file into a string with File.read, the idiomatic Ruby way.

Author: chris

Write Lines to a File in Perl

Open a file for writing and emit several lines, then close cleanly.

Author: chris