If you are like me coming from a Nodejs background, then there is a possibility that the whole logging using fmt.Printf and log.Printf and fmt.Errorf in golang may prove counter intuitive…So I made up the Nodejs/JS console.log like package that works on similar lines. You can get it by importing “github.com/julianfrank/console”
import ( "github.com/julianfrank/console" )
console.Log("Life is cool but Chennai is hot")
var city:="Chennai" var feel:="Hot" console.Log("%s is %s !",city,feel) //Outputs Chennai is Hot !
For Errors it gets even better as it returns the string formatted as per your pattern and returns an error object
err:=myerroneousFunction() errorObjectIWantToPassToLogger:=console.Error("Got this error in my function %s",err.Error()
If logging to console needs to be restricted then just trn the LogMode and ErrorMode on and off
console.ErrorMode=true//Turn on Logging to console on call console.LogMode=false//Stops Logging to console
Hope this makes life simpler! Enjoy!!