Skip to content

Allow an option for 'deterministic' iteration order for map prints #47

@xbeta

Description

@xbeta

Go (since 1.1) is well-known for having randomized map iteration order.

When iterating over a map with a range loop, the iteration order is not specified and is not guaranteed to be the same from one iteration to the next. Since Go 1 the runtime randomizes map iteration order, as programmers relied on the stable iteration order of the previous implementation.
https://blog.golang.org/go-maps-in-action

I actually use this kr/pretty module to do a simple string compare and found that the ordering is randomized.

Parameters: {\"date\":\"2020-08-20\", \"digit\":\"123\"}
vs

Parameters: {\"digit\":\"123\", \"date\":\"2020-08-20\"}

I am here requesting an option for the user to choose if they want to iterate map in an deterministic order or not. (By default, it should be not deterministic as recommended practice by Go)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions