Skip to content
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

text/template: {{range}} docs mention sorting "comparable" map keys, should say "ordered" instead #34147

Closed
MihaiB opened this issue Sep 6, 2019 · 1 comment

Comments

@MihaiB
Copy link
Contributor

@MihaiB MihaiB commented Sep 6, 2019

What did you do?

Read package docs for {{range pipeline}}:
https://golang.org/pkg/text/template/#hdr-Actions

What did you expect to see?

Map keys of an ordered type are visited in sorted key order.

What did you see instead?

Map keys of a comparable type are visited in sorted key order:

If the value is a map and the keys are of basic type with a defined order ("comparable"), the elements will be visited in sorted key order.

The spec defines comparable and ordered types as:
https://golang.org/ref/spec#Comparison_operators

The equality operators == and != apply to operands that are comparable. The ordering operators <, <=, >, and >= apply to operands that are ordered.

@gopherbot
Copy link

@gopherbot gopherbot commented Sep 6, 2019

Change https://golang.org/cl/193840 mentions this issue: text/template: docs: sort "ordered" (not "comparable") map keys

@gopherbot gopherbot closed this in 8a8cf5b Sep 6, 2019
@golang golang locked and limited conversation to collaborators Sep 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.