Enums in Go

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Stream - Scalable APIs for Chat, Feeds, Moderation, & Video.
Stream helps developers build engaging apps that scale to millions with performant and flexible Chat, Feeds, Moderation, and Video APIs and SDKs powered by a global edge network and enterprise-grade infrastructure.
getstream.io
featured
InfluxDB – Built for High-Performance Time Series Workloads
InfluxDB 3 OSS is now GA. Transform, enrich, and act on time series data directly in the database. Automate critical tasks and eliminate the need to move data externally. Download now.
www.influxdata.com
featured
  1. enum

    Type safe enums for Go without code generation or reflection (by orsinium-labs)

  2. Stream

    Stream - Scalable APIs for Chat, Feeds, Moderation, & Video. Stream helps developers build engaging apps that scale to millions with performant and flexible Chat, Feeds, Moderation, and Video APIs and SDKs powered by a global edge network and enterprise-grade infrastructure.

    Stream logo
  3. enumer

    A Go tool to auto generate methods for your enums (by dmarkham)

    I’ve found the enumer [0] library does the job of generating usable helpers without too much pain or any obvious downsides.

    Still, the lack of enums and enum/sum types remains by far my biggest gripe about Go.

    [0] https://github.com/dmarkham/enumer

  4. go-enum-encoding

    Generate Go enum encoding

    +1. Here is another alternative. I find this generator more lightweight and better syntax:

    https://github.com/nikolaydubina/go-enum-encoding

  5. exhaustive

    Check exhaustiveness of switch statements of enum-like constants in Go source code.

    There are two linters that add those checks: https://github.com/nishanths/exhaustive for values and https://github.com/alecthomas/go-check-sumtype for types. Both are integrated into golangci-lint. I use both a lot and have only a positive experience.

    Having support from the language would be nice, though.

  6. go-check-sumtype

    A simple utility for running exhaustiveness checks on Go "sum types."

    There are two linters that add those checks: https://github.com/nishanths/exhaustive for values and https://github.com/alecthomas/go-check-sumtype for types. Both are integrated into golangci-lint. I use both a lot and have only a positive experience.

    Having support from the language would be nice, though.

  7. go-enum

    An enum generator for go

    There's also https://github.com/abice/go-enum, which I decided to use after evaluating multiple such tools a while ago, but I don't remember exactly why it came out on top for me. Also, both (and others) have evolved since then, so things might have changed.

    One nice thing go-enum does is to even generate the consts, just from a list of values in a comment.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Flume/enthistory - History Tables For Ent

    3 projects | /r/golang | 15 Mar 2023
  • Go Enums Still Suck

    2 projects | news.ycombinator.com | 28 Mar 2024
  • Microservices communication

    3 projects | /r/golang | 9 Dec 2023
  • Enums?

    1 project | /r/golang | 8 Feb 2023
  • Does anyone know a pattern/library for creating editable generated files?

    1 project | /r/golang | 15 Jan 2023

Did you know that Go is
the 4th most popular programming language
based on number of references?