Debugging with Closures

This lesson discusses how debugging can be made easy with Go using closures.

When analyzing and debugging complex programs with myriads of functions in different code-files calling one another, it can often be useful to know which file is executing at certain points in the program and the line number of it. This can be done by using special functions from the packages runtime or log.

Debugging using runtime

In runtime, the function Caller() provides this information, so the closure where() could be defined, and then be invoked wherever it is needed:

Get hands-on with 1200+ tech skills courses.