From the course: Debugging in Go
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Introducing a program with a bug - Go Tutorial
From the course: Debugging in Go
Introducing a program with a bug
- [Instructor] So far in this course, we've learned how we can begin a new debugging session in various ways. Then we'd learned how we can use the different commands that are available to you within a debugging session, to inspect the program state and manipulate it. In this video, we're going to take a look at how we can put some of that knowledge to practice. Here we have an example program. This program populates a slice of person structs with various names, ages, and random IDs. Then it calls the find person function, which looks through the slice of person objects, and tries to find one with the given name. If that person is not found, we print out a message saying that we cannot find it. Otherwise, we print out a message saying that we found our person. Now, visually, when you look at this program, it seems like it should work. On line 42, we say find person, and the string passed in is Derek. And on line 28, we see the list of names that we populate with, and of course we do…