Then as long as your function followed the contract 0+ returns and then 1 `error` return, that could absolutely be turned into just the 0+ returns and auto-return error.
The fact that the `Error` interface is easy to match and extend, plus the common pattern of adding an error as the last return makes this possible.
There's not much broken with the error type itself, but the "real" problem is that the Go team decided not to change the way errors are handled, so it becomes a question of error handling ergonomics.
The article doesn't have a clear focus unfortunately, and I think it's written by an LLM. So I think it's more useful to read the struggles on the Go team's article
This means you can't pass variables in as function arguments. Even the example in the official go docs doesn't handle the scope correctly:
func main() {
var wg sync.WaitGroup
var urls = []string{
"http://www.golang.org/",
"http://www.google.com/",
"http://www.example.com/",
}
for _, url := range urls {
// Launch a goroutine to fetch the URL.
wg.Go(func() {
// Fetch the URL.
http.Get(url)
})
}
// Wait for all HTTP fetches to complete.
wg.Wait()
}
Delve into the world of Rust development with this blog post on creating a custom URL shortener, complete with tech stack analysis, middleware integration, and load testing.
Let's say you have this:
``` part, err := doSomething() if err != nil { return nil, err }
data, err := somethingElse(part) if err != nil { return nil, err }
return data, nil ```
Then as long as your function followed the contract 0+ returns and then 1 `error` return, that could absolutely be turned into just the 0+ returns and auto-return error.
The fact that the `Error` interface is easy to match and extend, plus the common pattern of adding an error as the last return makes this possible.
What am I missing here?