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

tour: Anonymous Struct Not Explained #690

Open
mattc41190 opened this issue Jan 24, 2019 · 0 comments
Open

tour: Anonymous Struct Not Explained #690

mattc41190 opened this issue Jan 24, 2019 · 0 comments

Comments

@mattc41190
Copy link

This issue is a lot like #412. In https://tour.golang.org/moretypes/9 there is usage of an anonymous struct. This is the first time a new comer is introduced to the concept that a composite type may be informally declared.

As a suggestion I would add this after https://tour.golang.org/moretypes/5 with the following simple explanation:

"Structs may be declared inline and without a name if the need arises for a one time use structure."

package main

import "fmt"

func main() {
	fmt.Println(struct{Greeting, Planet string}{"Hello", "World"})
}

The pros to including this explanation is that users are not caught off guard when they find it elsewhere in the tour or in the wild. The cons are that it may encourage less than perfectly idiomatic go code, but if that were the case the allowance of their existence in the spec is suspect.

Happy to create this if you guys would like :)

@mattc41190 mattc41190 changed the title Anonymous Struct Not Explained tour: Anonymous Struct Not Explained Jan 24, 2019
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

No branches or pull requests

1 participant