karan / joe

:running: A .gitignore magician in your command line
http://karan.github.io/joe/
MIT License
2.88k stars 210 forks source link

Utilise stderr for error reporting in "generate" #94

Open spukst3r opened 7 years ago

spukst3r commented 7 years ago

Right now joe generates all output to stdout, even error reports. So, if you run it like this:

joe g osX >> .gitignore

You'll end up with invalid .gitignore file. The most common practice for this is to utilise stderr stream, so that the error isn't redirected to the file and is written to the terminal instead. And nothing gets written to the file.

kendfss commented 2 years ago

Any of these should work:

l := log.New(os.Stderr, "", 0)
l.Println("log msg")
os.Stderr.WriteString("Message")
fmt.Fprintf(os.Stderr, "number of foo: %d", nFoo)

Generally [package name].Fprint[ln or f] allows you to write to open buffers.

here's a fork that implements the first solution.

source