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

Map literals code change unclear #1449

Open
crisman opened this issue Feb 22, 2023 · 0 comments · May be fixed by golang/website#195
Open

Map literals code change unclear #1449

crisman opened this issue Feb 22, 2023 · 0 comments · May be fixed by golang/website#195

Comments

@crisman
Copy link

crisman commented Feb 22, 2023

Between the code examples in "Map literals" and "Map literals continued"
https://go.dev/tour/moretypes/20
https://go.dev/tour/moretypes/21
it is less clear what changes between the code in 20 & 21 (the type name we can omit) the style is from:

    "Google": Vertex{
        37.42202, -122.08408,
    },

to

    "Google":    {37.42202, -122.08408},

making three changes (single line the block, adding space for value alignment, and removing the type)
makes it harder to understand what the article is pointing out.

crisman added a commit to crisman/golang_website that referenced this issue Feb 23, 2023
Between 'map-literals.go' and 'map-literals-continued.go' there are four
changes (omit element type, single line the block, add space to align
the "Google" element, and remove the terminal comma in the block) which
makes it hard for reader a to understand what it is "you can omit" in the
'Map literals continued' section of 'moretypes.article'.

To avoid the three text changes that the article does not talk about,
update the before code in 'map-literals.go' to already be formatted on a
single line per map entry.

Also add code examples in the article explaining the two versions and
why the literal element type may be elided.

Fixes golang/tour#1449
crisman added a commit to crisman/golang_website that referenced this issue Feb 23, 2023
Between 'map-literals.go' and 'map-literals-continued.go' there are four
changes (omit element type, single line the block, add space to align
the "Google" element, and remove the terminal comma in the block) which
makes it hard for a reader to understand what it is "you can omit" in
the 'Map literals continued' section of 'moretypes.article'.

To avoid the three text changes that the article does not talk about,
update the before code in 'map-literals.go' to already be formatted on a
single line per map entry.

Add code examples in the article explaining the two versions and why the
literal element type may be elided.

Fixes golang/tour#1449
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant