From c26d39284c3dca31cae16760f939d3daeb7fd44f Mon Sep 17 00:00:00 2001 From: Niklas Fasching Date: Tue, 18 Dec 2018 23:46:41 +0100 Subject: [PATCH] Improve main.go: log error to stderr, output to stdout --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index e2b1edf..f72db9d 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "bytes" + "fmt" "io/ioutil" "log" "os" @@ -15,11 +16,10 @@ import ( ) func main() { - log.SetFlags(0) - log.SetOutput(os.Stdout) + log := log.New(os.Stderr, "", 0) if len(os.Args) < 3 { log.Println("USAGE: org FILE OUTPUT_FORMAT") - log.Fatal("supported output formats: org, html, html-chroma") + log.Fatal("Supported output formats: org, html, html-chroma") } path := os.Args[1] bs, err := ioutil.ReadFile(path) @@ -43,7 +43,7 @@ func main() { if err != nil { log.Fatal(err) } - log.Print(out) + fmt.Fprint(os.Stdout, out) } func highlightCodeBlock(source, lang string) string {