From 483098e7bf001d5e67b5cb7cf0e4f1ccaaccfedf Mon Sep 17 00:00:00 2001 From: Taylor Blau Date: Wed, 1 Aug 2018 11:59:22 -0500 Subject: [PATCH] docs/man/mangen.go: move fmt.Fprintf to warnf, too For fatal error messages, let's move calls to fmt.Fprintf to a 'warnf' function so that the call-sites appear similar to that of 'infof'. --- docs/man/mangen.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/man/mangen.go b/docs/man/mangen.go index 59fba051..94ab174f 100644 --- a/docs/man/mangen.go +++ b/docs/man/mangen.go @@ -15,6 +15,10 @@ func infof(w io.Writer, format string, a ...interface{}) { fmt.Fprintf(w, format, a...) } +func warnf(w io.Writer, format string, a ...interface{}) { + fmt.Fprintf(w, format, a...) +} + func readManDir() (string, []os.FileInfo) { rootDirs := []string{ "..", @@ -29,7 +33,7 @@ func readManDir() (string, []os.FileInfo) { } } - fmt.Fprintf(os.Stderr, "Failed to open man dir: %v\n", err) + warnf(os.Stderr, "Failed to open man dir: %v\n", err) os.Exit(2) return "", nil } @@ -45,7 +49,7 @@ func main() { manDir := filepath.Join(rootDir, "docs", "man") out, err := os.Create(filepath.Join(rootDir, "commands", "mancontent_gen.go")) if err != nil { - fmt.Fprintf(os.Stderr, "Failed to create go file: %v\n", err) + warnf(os.Stderr, "Failed to create go file: %v\n", err) os.Exit(2) } out.WriteString("package commands\n\nfunc init() {\n") @@ -69,7 +73,7 @@ func main() { out.WriteString("ManPages[\"" + cmd + "\"] = `") contentf, err := os.Open(filepath.Join(manDir, f.Name())) if err != nil { - fmt.Fprintf(os.Stderr, "Failed to open %v: %v\n", f.Name(), err) + warnf(os.Stderr, "Failed to open %v: %v\n", f.Name(), err) os.Exit(2) } // Process the ronn to make it nicer as help text