HN user

zarldev

4 karma
Posts3
Comments11
View on HN

I stand corrected. Still you cannot implement an Is on a sentinel error and is only applicable to concrete error types. And if I'm using concrete types I'm going to us errors.As

In standard go you would not implement Is but would use the errors.Is call. How would this work if it is a sentinel error as you would use with errors.Is??

the values are specified in the definition of the iota type.

``` type planet int // Gravity[float64],RadiusKm[float64],MassKg[float64],OrbitKm[float64],OrbitDays[float64],SurfacePressureBars[float64],Moons[int],Rings[bool] ```

Go Enums Suck 2 years ago

But all go generate does is run a binary like stringer? This can be used in go generate.

Go Enums Suck 2 years ago

DSL? The go way is to use go generate I would say and it can be used with go:generate, I would like to use the AST lib to parse go files to remove the need for any json and to be more like the cmd stringer tool.

Go Enums Suck 2 years ago

Hey did you read to the bottom of the article. It shows that that was just a temporary solution, the real invalid code is

func (t operation) IsValid() bool { _, ok := strOperationMap[s] return ok }

Tbh it has been updated to us an array instead for string indexing.