Error Tracing Tips on Golang

Noval Agung Prayogo
The Startup
Published in
4 min readOct 5, 2020


Image by Elijah G

Have you ever face a situation where an error is occurred on your code, but not quite sure on which file it is exactly happening? Then me too 😁

In real-life app development, where our app is most likely coded in a ton of files, finding the root cause of an error is quite time-consuming.

Usually during the development process, sometimes we dispatched a client HTTP call for testing purposes to a bugged endpoint on our web service. We expecting an error on the response, and there it is, a logical error occurred. We need to fix it, fast! A.S.A.P!

Naturally what we developer will do in the first place is gathering the error messages from the client HTTP call response, from the backend error log, from other places. And then we will proceed with doing the root cause analysis, and one of it is predicting the possible location of the file, function, line of the code where the error is occurred based on the clue from error messages. If the clue is clear enough we might able to get the line of code in no time. Otherwise ….

  1. Check the route handler to get the controller class
  2. And then go to the controller code, to check the action method
  3. And then go to the model codes, go to service codes
  4. And then go to database package code