Compile-time safety for enumerations in Go

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

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • exhaustive

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

  • This is an analyzer that will catch this: https://github.com/nishanths/exhaustive

    I believe it's in golangci-lint.

  • go

    The Go programming language

  • https://github.com/golang/go/issues/57644

    As stated in that proposal, the interaction between what people want from “enums,” “discriminated unions,” “sum types,” (as well as “optional values” and “nil safety”) and fundamental Go tenets like zero values, make this a tough sell, which is very likely to make no one happy.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • go-enum-example

    Go Enum: benchmarks, examples, analysis

  • interesting approach! but I typically use this method for type constraints.

    for enums I prefer just direct structs: https://github.com/nikolaydubina/go-enum-example

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