this post was submitted on 27 Feb 2024
15 points (85.7% liked)

Golang

2247 readers
1 users here now

This is a community dedicated to the go programming language.

Useful Links:

Rules:

founded 2 years ago
MODERATORS
15
Go Enums Suck (www.zarl.dev)
submitted 10 months ago by bugsmith to c/golang
you are viewing a single comment's thread
view the rest of the comments
[–] canpolat 6 points 10 months ago

I mainly develop in C#, and I agree that having to write so much boiler plate for type safety is really boring. C# is not perfect either (it doesn't have discriminated unions, etc.) but at least it gives type safety out of the box.

However, in general, I think enums are widely misused. I see a lot of cases where they should have been classes with a factory, but ended up being enums with a lot of static functions and switch statements.