Skip to content

proposal: natively built-in enumerated types syntax for Go #71891

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

Closed
duc18020319 opened this issue Feb 22, 2025 · 2 comments
Closed

proposal: natively built-in enumerated types syntax for Go #71891

duc18020319 opened this issue Feb 22, 2025 · 2 comments
Labels
LanguageProposal Issues describing a requested change to the Go language specification. Proposal
Milestone

Comments

@duc18020319
Copy link

duc18020319 commented Feb 22, 2025

Go version
go version go1.24.0 windows/amd64

What did I do and see happen?
Normally, if an enumerated type is created in Go (using a code snippet in Web):

package main

import "fmt"

const (
	ENUMERATED_VALUE_1 = iota
	ENUMERATED_VALUE_2 = iota
	ENUMERATED_VALUE_3 = iota
	ENUMERATED_VALUE_4 = iota
)

, which doesn't have a name.

What did I expect to see?
Enumerated types (enums) can be declared natively by the language like this:

type Enumeration enum {
	ENUMERATED_VALUE_1,
	ENUMERATED_VALUE_2,
	ENUMERATED_VALUE_3,
	ENUMERATED_VALUE_4,
}

, rather than using constants and 'iota', like enums in C.

@gopherbot gopherbot added this to the Proposal milestone Feb 22, 2025
@duc18020319 duc18020319 changed the title proposal: import/path: proposal title Natively built-in enumerated types syntax for Go Feb 22, 2025
@duc18020319 duc18020319 changed the title Natively built-in enumerated types syntax for Go proposal: natively built-in enumerated types syntax for Go Feb 22, 2025
@gabyhelp
Copy link

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@gabyhelp gabyhelp added the LanguageProposal Issues describing a requested change to the Go language specification. label Feb 22, 2025
@ianlancetaylor
Copy link
Contributor

Closing as a dup of #19814.

@ianlancetaylor ianlancetaylor closed this as not planned Won't fix, can't repro, duplicate, stale Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LanguageProposal Issues describing a requested change to the Go language specification. Proposal
Projects
None yet
Development

No branches or pull requests

4 participants