I have a struct wrapping a time.Time
object and would like to format it in a human readable way.
package main
import (
"time"
"fmt"
)
type TimeStruct struct {
t time.Time
}
func main() {
t := time.Now()
fmt.Printf("time: %v
", t) // nice
ts := TimeStruct{t: t}
fmt.Printf("time struct: %#v
", ts) // ugly
}
(Play)
Why doesn't Go format the t
field in TimeStruct
the same as a plain time.Time
object? Is there a simple way to format this in a readable way (without defining extra methods for it)?