3 ms·
It defaults to not running the rest if a step fails, and the error result is accessible via usual mechanisms. _, err := script.Foo(...).Bar(...).Stdout();
by mst 3y ago
It defaults to not running the rest if a step fails, and the error result is accessible via usual mechanisms.
_, err := script.Foo(...).Bar(...).Stdout();
if err != nil {
log.Fatal(err)
}
is sufficient for a quick scripting hack designed to be run interactively.
I don't see it as a lot different to bash scripts with -e and pipefail set, which is generally preferable anyway.
Plenty of go code does
if err != nil {
return nil, err;
}
for each step and there are plenty of cases where you only care -if- it failed plus a description of some sort of the failure - if you want to proceed on some errors you'd split the pipe up so that it pauses at moments where you can check that and compensate accordingly.
(and under -e plus pipefail, "error reported to stdout followed by aborting" is pretty much what you get in bash as well, so I'm unconvinced it's actually going to be harder to debug)