Search⌘ K

Developing a Basic Phone Book Application

Explore how to create a basic phone book application in Go by implementing user-defined data types, slices, and functions for searching and listing entries. Understand command-line utility design and gain foundational skills for managing data in Go programs.

Introduction

In this lesson, to utilize the skills we’ve picked up so far, we will develop a basic phone book application in Go. Despite its limitations, the presented application is a command-line utility that searches a slice of structures that is statically defined (hardcoded) in the Go code. The utility offers support for two commands named search and list that search for a given surname and return its full record if the surname is found and lists all available records, respectively.

Shortcomings

The implementation has many shortcomings, including the following:

  • If we want to add or delete any data, we need to change the source code.

  • We can’t present the data in a sorted form, which might be OK when we have three entries but might not work with more than 40 entries.

  • We can’t export our data or load it from an external file. ...