-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussion about formatting #55
Comments
What did you have in mind for a machine readable output?
Yeah, I definitely agree with this. I think this also extends into any nonessential information we display about variables, i.e. displaying len and cap for slices is most likely unnecessary. Maybe we have a command to display extended information about a variable, including type and any other metadata associated with it.
Absolutely.
Good idea, maybe a flag for the print command, or a runtime configuration to enable pretty printing? I'm definitely open to suggestions. |
Not sure, maybe json? Something standard so people can focus on integration rather than on how to parse the output.
I like GDB's combo of runtime config + startup script to set the defaults. Opens a lot of doors for customizing other output such as switching to machine readable output, chaning the default number of elements etc. |
JSON sounds fine to me.
Currently, there's no real way to configure Delve. I'd definitely like to talk through adding configuration to Delve. A startup script, or some sort of config file in the users home dir paired with maybe a command to set / list runtime variables. |
+1 on JSON, it's pretty clear - definitely being able to log/redirect output to a file also (cf set logging file ) and enable/disable pagination for human interaction and scripted modes. |
I also wonder if being able to output runtime/debug and pprof style info directly in delve would be useful. At least a quick hook to dump expvar into json may be worth it even if not the heap/gc/profile hooks. |
May I suggest https://github.com/kr/pretty as a possible solution for pretty printing structs / maps. As a small example: package main
import "github.com/kr/pretty"
func main() {
type (
miniStr struct {
mini string
}
str struct {
payload string
payload2 miniStr
}
)
a := map[string]map[string]str{
"a": map[string]str{
"b": str{
payload: "c",
payload2: miniStr{
mini: "d",
mini2: "e",
},
},
},
"a2": map[string]str{
"b2": str{
payload: "c2",
payload2: miniStr{
mini: "d2",
mini2: "e2",
},
},
},
}
pretty.Printf("%# v\n", a)
}
|
Moving discussion related issues to mailing list. Please see (https://groups.google.com/forum/#!forum/delve-dev) for further discussion. |
* Remove brackets from the multipart contentids * Removed the siml/smil mistake and the '.' on images
Now that delve supports a majority of types, including complex arrays and structs I think it is worth looking at how to properly display them.
Here are my thoughts so far to get the discussion started.
Support both a human readable format and a separate machine readable output format (for IDE integration).
Standardize when the type name is shown in the human readable format. My first thought is to never show it when using the print command and add a ptype command to print the type of a variable on demand.
Support slice syntax for printing arrays.
print x
prints the first 64 elements,print x[0]
prints the first element,print x[10:12]
prints elements 10 to 12 etc.Support pretty-printing for structs. This could be switched off and on. For example:
Compact:
Pretty:
The text was updated successfully, but these errors were encountered: