Sort map keys. Expand maps unconditionally when len() > 2#25
Open
Sort map keys. Expand maps unconditionally when len() > 2#25
Conversation
Collaborator
|
Thanks for the PR, especially including the tests! It is quite possible to use structs as a map key. See "Key types" in the article here: https://blog.golang.org/go-maps-in-action |
It's enough to declare and assign it when we actually need it a couple of lines below.
Currently the documentation for github.com/kr/pretty is not displayed on
pkg.go.dev because of license restrictions:
https://pkg.go.dev/github.com/kr/pretty?tab=doc
This is almost certainly because the License file includes an errant
header:
The MIT License (MIT)
The actual MIT license does not include this header:
https://opensource.org/licenses/MIT
GitHub and other interfaces surface the type of the license through
automatic detection (as will pkg.go.dev). Hence this header is
superfluous in any case.
Whilst we are at it, tidy up go.mod and add go.sum.
See golang/go#32479 Fix kr#65. Signed-off-by: Robert-André Mauchin <zebob.m@gmail.com>
This prevents infinite recursion, similar to the fixes to the formatter in kr#13. In addition to detecting cycles, we also check that the two values contain the same cyclic structure.
Implements a new function less() to compare two map key value. Include 92% of test coverage of this function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements a new function less() to compare two map key value. Include 92% of
test coverage of this function.
The missing part is comparing struct but it's impossible to use struct as map key so it is not a big deal.