Using Go language to make chain call, how to realize the direct return after one call reports an error, without executing the following call?

  golang, question

For example,v := a(x).b(y).c(z)Ifb(y)An error has occurred. How can the implementation not run without execution?c(z)Direct return?
If you use panic, the whole program will collapse if you don’t recover. If you recover in b(y), you still have to run c(z). If you recover outside, it is not beautiful.

Looks like you need PHP 7 or Swift’sNull coalescing operatorWhat? Of course, Haskell also supports this kind of thing.