-
-
Notifications
You must be signed in to change notification settings - Fork 348
Closed
Description
Several people have noted that the behaviour of Stdout is a bit puzzling when there's an error in the pipe, especially for beginners: it just prints nothing! Unless the program checks the return value of Stdout, there's nothing to indicate that an error happened.
To make it easier to write one-liners, I propose an Exit method that behaves like Stdout, but also prints any pipe error to stderr and calls os.Exit with the appropriate exit status. For example:
script.Get(URL).Exit()Depending on the HTTP response, we might see as a result:
HTTP/1.1 404 Not Found
with
echo $?
1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels