Updating the Phone Book Application

Let’s implement some modifications in our phone book application.

Now that we know how to generate random numbers and random strings, we are going to revisit the phone book application and use these techniques to populate the phone book with random data.

Populating the phone book with random data

In this lesson of the course, we are going to create a function that populates the phone book application from the previous chapter with random data, which is pretty handy when we want to put lots of data in an application for testing purposes.

The biggest change in this version of the phone book application is that the searching is based on the telephone number because it is easier to search random numbers instead of random strings. But this is a small code change in the search() function—this time, search() uses v.Tel == key instead of v.Surname == key in order to try to match the Tel field.

Implementation details

The populate() function of phoneBook.go does all the work—the implementation of populate() is the following:

Get hands-on with 1200+ tech skills courses.