Skip to content

proposal: Go 2: more idiomatically way to define enums #64739

Closed as not planned
Closed as not planned
@nightway1

Description

@nightway1

Go Programming Experience

Intermediate

Other Languages Experience

Python

Related Idea

  • Has this idea, or one like it, been proposed before?
  • Does this affect error handling?
  • Is this about generics?
  • Is this change backward compatible? Breaking the Go 1 compatibility guarantee is a large cost and requires a large benefit

Has this idea, or one like it, been proposed before?

Yes.

I am making this proposal since the last proposal I found was from 2017, it is better that there is a more current one, on that topic they spoke very positively about it being in go, so you already know what to do.

Does this affect error handling?

No.

Is this about generics?

No.

Proposal

add a much better way of defining enums, like:

type BetterEnum enum { FIRST = "enumsaregood" SECOND = "oldenumsarebad" }

According to me and many, it is a much more readable way than doing things with constants and types.

Language Spec Changes

No response

Informal Change

No response

Is this change backward compatible?

Yes.

There is no way to remove the old way of doing it, because they would remove the constants and that makes no sense.

Orthogonality: How does this change interact or overlap with existing features?

No response

Would this change make Go easier or harder to learn, and why?

No response

Cost Description

No response

Changes to Go ToolChain

No response

Performance Costs

No response

Prototype

(#19814)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions