-
Notifications
You must be signed in to change notification settings - Fork 56
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
Issues/34: More compact array/map representation #43
Conversation
This is because slices are now compacted and as such are not easier on the eyes when looking at testdata/primitives.dump
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern here is wrapping. If you have a slice or map of a certain number of elements, they are going to all be on the same line.
I looked at implementing a compact mode for slices/maps at one point, but ran into the problem that you need to handle wrapping and indentation everywhere, and I didn't bother finishing it. Ideally, indentation and wrapping should be handled at the writer level.
case reflect.Bool, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64, reflect.String: | ||
// Where the elements in a slice/array are primitive types; dump in a compact manner | ||
original := s.config.Compact | ||
s.config.Compact = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should never mutate the configuration, which might be shared across multiple concurrent goroutines, and might be a constant at the caller's end. Let's add the flag to dumpState
directly.
I have given this a little more thought. I think the work needed here is a little more than I had imagined.
|
Thank you! I might revisit this at some point. It's annoying, I agree. |
What:
Why: