4 ms·
>No enums? [...] We're stuck with magic numbers? In go you don't strictly need magic numbers because you can define constants: type Status int const (
by benrazdev 9mo ago
>No enums? [...] We're stuck with magic numbers?
In go you don't strictly need magic numbers because you can define constants:
type Status int
const (
IoProblem Status = iota // we start at zero and go down from there
JsonParse
...
)
The problem is that there is no exhaustiveness with these constant groups. The type Number is not a closed set of just IoProblem and JsonParse like an enum in C. It is just an int.