5 ms·
The Go code in your example could actually be written: resp, err := http.Get(someURL) if err != nil { return nil, err } return DoStuff(
by greenbast 10y ago
The Go code in your example could actually be written:
resp, err := http.Get(someURL)
if err != nil {
return nil, err
}
return DoStuff(resp)
- marcosdumay 10y agoYeah, but if you had 5 operations in Haskell, you'd write: do a <- operation1 operation2 a -- This one returns nothing b <- operation3 a c <- operation4 b operation5 c In Go, you'll keep repeating that 'if err != nil {' everywhere. And things get way more interesting with more complex monads, but error handling is simple.