I've been trying to write a very simple program today that is like cat but makes everything uppercase.
Technically it works as expected at the command line. But I'm running it via an NSTask within an OS X app, and it's giving me exit status code 11 with nothing printed to stdout or stderr. I know it's not a problem with NSTask because using it with the actual `cat` command works just fine (exit code 0, prints everything from stdin to stdout).
Can anyone spot a flaw in this Go program that would cause such an issue to arise? Here's what I have:
b, _ := ioutil.ReadAll(os.Stdin)
s := strings.ToUpper(string(b))
io.WriteString(os.Stdout, s)
//os.Stdout.Sync()
//os.Stdout.Close()
}
As you can see I've also experimented with trying to manually flush and close Stdout, to no avail.
Any ideas?
-Steven