Representative Line: Log Every Error
by Remy Porter from The Daily WTF on (#4DVTH)
Tom C inherited some Go from another developer, and writes, "I'm pretty sick of finding this sort of stuff in this code."
if log, err = dockerservice.GetLoggerInstance(); err != nil {log.Err(fmt.Sprintf("Logger error: %v \n", err)) }
It's good to log every error- it'll help in the long run when you're trying to trace through the problem which happens in production but the program works fine on your machine. This code knows that accessing the logger object is code that can throw an error, so if it gets an error fetching the logger object it" logs the error. With the logger object that returned some kind of error.
[Advertisement] Forget logs. Next time you're struggling to replicate error, crash and performance issues in your apps - Think Raygun! Installs in minutes. Learn more.