I want to create a function that will work exactly like fmt.Printf
but also left pad the string with current timestamp. Ideally I would like to override printf and println to do this job, but the first solution is also ok.
This is what I've done:
func output(message string, a ...interface{}) {
fmt.Printf(getCurrentTime() + " " + message, a)
}
func getCurrentTime() string {
t := time.Now()
return t.Format("[2006-01-02 15:04:05]")
}
But it outputs strange results when I pass variables.
How should I do this?