Fundamentals of I/O in Go: Part 3

submited by
Style Pass
2024-04-24 12:00:07

Welcome to the final part of the Fundamentals of I/O series, where we will learn about buffered I/O. If you haven’t already, I recommend checking out the first two parts:

When programs want to do something(e.g., open a file, send data via the network, create a process, etc.), they ask the operating system to do it via system calls(syscalls).

These system calls are similar to regular function calls, but they involve some extra steps that cause the CPU to switch from user mode to kernel mode so it can execute a privileged action.

This output can be pretty verbose because, most of the time, you don’t want to see all the syscalls. You can filter for a specific syscall by using the -e option.

which means that the 13 bytes of /home/andrei\n are successfully written to file with the descriptor 1 (the standard output in Linux). That’s all you need to know for this article, but if you want to learn more, check out this zine made by Julia Evans.

I like strace because it helps me see what a program is doing even if I can’t access the source code. Some people call strace the Sysadmin’s Microscope, but I view it more as a stethoscope. A compiled program is like a black box, but that doesn’t mean we cannot hear what’s inside with the help of strace.

Leave a Comment