Spyke
programming.dev

I would rename Check to Must which there is at least some precedent for.

3
lemmy.world

I don’t think it is a taboo, but it is possibly just worse code in many cases. Handling error values is usually something that should be done thoughtfully. Panic is nice but can easily be overused and should not make it out of a package.

I too wish there was a better way, but in the form of proper enums and result and option types. However, wrapping in functions is fine in some cases not taboo.

As an aside, you probably don’t need a static union type for your min and max functions. I assume you could use comparable.

3
danhab99reply
programming.dev

As an aside, you probably don’t need a static union type for your min and max functions. I assume you could use comparable.

comparible only allows ==

2
theherkreply
lemmy.world

Oh right! What am I saying? contraints.Ordered maybe.

2

I just looked at the standard docs and I didn't realize there was a built-in min and max function. Y'all should really read the standard lib docs.. it's fascinating in there.

1

I too consider that if err != nil a bit complicated to type. Most times, I wrap it away in a function like your Check0. I know that the major "framework" for command line applications (cobra) has a similar logic with its checkError function.

-4

You reached the end

I kinda wish there was a better way to do if err != nil in go | Spyke