6 ms·
> First, generic methods are now supported > Generic functions can now be used without explicit type arguments Great! This was an ergonomic code issue I hit wh
by Xeoncross 28d ago
> First, generic methods are now supported
> Generic functions can now be used without explicit type arguments
Great! This was an ergonomic code issue I hit when trying to create a universal handler/controller generic that could hydrate/populate function arguments (from a request body) without having an actual copy of the arguments: https://github.com/xeoncross/mid/blob/main/handler.go#L12 https://github.com/xeoncross/mid/blob/main/handler.go#L12
- iaaan 28d agoNeat, stealing this.
- Xeoncross 28d agoI wrote a blog on it if you're interested: https://xeoncross.com/2026/better_go_handlers.html https://xeoncross.com/2026/better_go_handlers.html
- greg9381 28d agoThanks for the link, looks like a very pleasant framework to use! I was interested to see "Mid-fasthttp" on the slower end in the benchmarks at the bottom, do you know why that is? Btw, the Gin and Echo examples reference an "input" variable but it doesn't seem to be defined there? Maybe it was intentional, since the examples are just to give a general idea of how the handler looks in each library, but thought I would let you know just in case it wasn't.
- Xeoncross 28d agoDue to the fact that fasthttp is not net/http compatible it is due to the conversion being required from a https://pkg.go.dev/net/http#Handler https://pkg.go.dev/net/http#Handler. It was included for information purposes as I though someone would be curious.
- knocte 28d agoCan proper Result/Option types be created for Go now?
- dgunay 28d agoYou can do pipelined option/result manipulation now, but without sum types/pattern matching it's not going to be quite as useful as Rust's.