golang / tour

[mirror] A Tour of Go
BSD 3-Clause "New" or "Revised" License
1.53k stars 521 forks source link

tour: Suggestion: Add a page or two for how to do enums the Go way (for devs coming from other languages) #1591

Open JamesC01 opened 4 months ago

JamesC01 commented 4 months ago

Context: https://go.dev/tour/moretypes/

I think it would be really beneficial to describe the idiomatic Go way of doing something like enums from other languages, (using constants wrapped in (), or using iota, using both of those with a custom type etc.) I searched for a bit, and it seems like there isn't a single official Go resource mentioning that these are the alternative to using enums, I only found third-party articles and stackoverflow questions, so I think it would be very beneficial to add one or two pages to the tour in the "moretypes" section explaining how you do this in Go, for people who are coming from other languages. I only just started learning Go yesterday, so I'm not sure how to write a page, so hopefully someone who knows their stuff can.