-
Book Overview & Buying
-
Table Of Contents
Practical Systems Programming in Go
By :
In this section, we will implement in Go the which(1) utility, a classic Unix command that locates the executable file associated with a given command by searching through the directories listed in the PATH environment variable. This exercise introduces working with environment variables and executable file detection in Go. We will leverage the os and path/filepath packages to inspect directories, combine paths, and verify permissions.
When we say idiomatic Go, we mean writing Go code in the style and spirit that the Go community has collectively embraced as natural, clear, and efficient. Every programming language has its own set of unwritten rules and conventions beyond mere syntax, and in Go, these idioms emphasize simplicity, readability, and explicitness. For example, idiomatic Go favors using short variable names in small scopes (i, n, err), handling errors immediately rather than deferring them, and returning multiple values instead of exceptions. It also...