-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
In 2019, Russ Cox acknowledged three of the most commonly reported Go pain points:
> The top three pain points for Go users, in surveys and direct feedback, have been consistent for a number of years. They are: package management, generics, and error handling. We are working on all three.
The first has been solved, the second is in the process of being solved, and the third has been addressed in two major proposals, both of which were rejected. I sympathize with the author's frustration, though I would argue that better error handling in Go is still being actively discussed and investigated.
https://twitter.com/_rsc/status/1146129898383302656
https://go.dev/blog/go2draft
1. Package management has, more or less, been solved through minimum version selection in modules/vgo. Though not everyone's favorite, at least it doesn't require a SAT-solver (dependency hell is NP-complete https://research.swtch.com/version-sat)
https://github.com/golang/go/issues/24301
https://go.googlesource.com/proposal/+/master/design/24301-v...
https://research.swtch.com/vgo
https://golang.org/ref/mod
https://github.com/golang/go/wiki/Modules
https://go.dev/blog/using-go-modules
https://golang.org/doc/tutorial/create-module
2. Parametric polymorphism/Type Parameters ("generics") is/are being introduced into the language in 1.18, which is slated for release in early 2022.
https://github.com/golang/go/issues/43651
https://go.googlesource.com/proposal/+/master/design/43651-t...
3. There have now been a couple of proposals to make error handling simpler and reduce boilerplate
https://github.com/golang/go/wiki/Go2ErrorHandlingFeedback
check/handle
https://go.googlesource.com/proposal/+/master/design/go2draf...
https://go.googlesource.com/proposal/+/master/design/go2draf...
try
https://github.com/golang/go/issues/32437
https://go.googlesource.com/proposal/+/master/design/32437-t...
related
https://go.googlesource.com/proposal/+/master/design/go2draf...
https://go.googlesource.com/proposal/+/master/design/go2draf...
https://go.googlesource.com/proposal/+/master/design/go2draf...
(This isn’t exactly how it’s implemented—that detail is unstable and has actually changed <https://github.com/rust-lang/rfcs/pull/3058> since ? was stabilised!—but it’s equivalent in this instance. As examples of how it’s not exact: you can use ? on Option too; and inside a try block (unstable), ? isn’t a return, acting more like a break-with-value.)
For wrapping the error: note the .into() in the desugaring: it’ll perform any necessary type conversions which is the normal way you’d do error wrapping. But if you want to do anything more than that, or adding specific context, you’re still in luck! You can use method chaining to manipulate the result. In the standard library is map_err <https://doc.rust-lang.org/std/result/enum.Result.html#method...>:
foo().map_err(|err| f(err))?