Search⌘ K
AI Features

Developing the which(1) Utility in Go

Explore how to develop a Go-based version of the which utility that finds executable files by reading command-line arguments, accessing the PATH environment variable, and checking file properties to understand Go's interaction with the OS.

Let’s now discuss a practical example for developing a Go version of the which(1) utility, which locates a program file in the user's PATH value.

Go can work with our operating system through a set of packages. A good way to learn a new programming language is by trying to implement simple versions of traditional UNIX utilities. In this lesson, we’ll see a Go version of the which(1) utility, which will help us understand the way Go interacts with the underlying OS and reads ...