Avatar ·

How to correctly and idiomatically implement enums in Go?

Hi everyone! I'm new to Go, coming from Java and Python, and I can't find a clear answer to a simple question: how to do enums in Go?\n\nIn Java I used to write:\n\n```java\npublic enum Season {\n WINTER, SPRING, SUMMER, AUTUMN\n}\n```\n\nIn Python I use `Enum` from the standard library. But in Go I only see `const` and `iota`, which seems illogical — just numbers, with no guarantee that someone won't pass 999 instead of my "enum".\n\nI need to implement an order status:\n\n- New\n- Processing\n- Shipped\n- Delivered\n- Cancelled\n\nI want:\n\n1. Strong typing (cannot pass an arbitrary number).\n2. Convenient output of status as a string for logs and user.\n3. Ability to check that a value belongs to a valid set.\n\nHow to do this correctly