I often create small multi-value flag types, e.g.
```go
type mode uint8
const (
argMode mode = iota
baseMode
cmdMode
)
```
The problem is that if I write, say, `m := baseMode`, although `m` has the correct type (`mode`), there is no way to constrain its values to the consts I've declared.
In theory I could create a `NewMode(int) mode` function and have it panic if the given int isn't valid; but that won't prevent, say, `m += 99`. The next step would be to define a full type, e.g., something like:
```go
type mode struct {
m int
}
```
This would prevent `m++` and similar since all accesses would have to go through the public functions. However, this would still do all its checking at _runtime_; whereas for this kind of use it should surely be possible to check at compile time.
In Pascal it is easy to declare a "subrange" type which might look like this in Go-like syntax:
`type mode uint8 0..2`
Is there a compile-time solution for this that I've missed?