Please answer the following before submitting your issue:
Note: Please include any substantial examples (debug session output,
stacktraces, etc) as linked gists.
dlv version)?go version)?package main
import (
"fmt"
"time"
)
func main() {
t:=time.Now()
fmt.Println(t)
}
and run
dlv debug
b main.main
c
...
print t
2017-10-23 11:03:00 ...time.Time {
wall: 13723543243807126424,
ext: 4158612300,
loc: *time.Location {
name: "",
zone: []time.zone len: 0, cap: 0, nil,
tx: []time.zoneTrans len: 0, cap: 0, nil,
cacheStart: 0,
cacheEnd: 0,
cacheZone: *time.zone nil,},}
How to get formatted time text in dlv debug mode?
time.Duration too. Is it possible to get this with breakpoints and print command?
@aarzilli I looked at your fork? Can you also print out time.Duration in a format that is better than the default (nanoseconds)?
I'd rather not:
Can you explain point 3 please?
Re Point1:
For 99.9% for programs, nanoseconds is not used for anything in practice. It's not trivial to convert from nanoseconds to minutes or hours in your head, yet for many human-facing applications, we work in minutes or hours.
For non-human facing applications, milliseconds or seconds is fine and it's easy to convert from nanoseconds to them.
Go's own string representation of time.Duration, recognising the facts above, print out durations in a format like 9h15m
Can you explain point 3 please?
If you have go 1.10 installed and dt is a variable of time.Duration the command print dt/time.Millisecond will print dt in milliseconds.
Right now I'm working on a configurable deadline-calculation package, so I'm looking forward to being able to make sense of the time.Time values I see when debugging. I think the pretty-print PR above would be sufficient for all use cases I've encountered so far.
For a given time.Time value t, is there a way to see or print t.Unix() or t.UnixNano() now?
Closing, you can instead call methods on the time value to format via the call t.Format(...) or call t.String().
Closing, you can instead call methods on the time value to format via the
call t.Format(...)orcall t.String().
you can not call these function when dealing with coredump file
If I would be interested in calling t.Format(...) or t.String() then why would I be using a debugger in first place?
I would rather go directly for fmt.Printf(...) instead!
Most helpful comment
Closing, you can instead call methods on the time value to format via the
call t.Format(...)orcall t.String().