From e5a9d29215866d90e6a59b62622a651e1938719e Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 22 Feb 2020 04:32:51 -0500 Subject: [PATCH 1/2] refactor: use Println in favor of Fprintln for os.Stdout --- plugins/common/common.go | 2 +- plugins/common/log.go | 6 +++--- plugins/common/src/prop/prop.go | 14 +++++++------- plugins/network/triggers.go | 14 +++++++------- plugins/resource/triggers.go | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/plugins/common/common.go b/plugins/common/common.go index ef5485b2a..19cb1195a 100644 --- a/plugins/common/common.go +++ b/plugins/common/common.go @@ -383,7 +383,7 @@ func ReportSingleApp(reportType string, appName string, infoFlag string, infoFla for _, k := range flags { if infoFlag == k { v := infoFlags[k] - fmt.Fprintln(os.Stdout, v) + fmt.Println(v) return } } diff --git a/plugins/common/log.go b/plugins/common/log.go index e60e912c4..1f8cd8593 100644 --- a/plugins/common/log.go +++ b/plugins/common/log.go @@ -14,7 +14,7 @@ func LogFail(text string) { // LogInfo1 is the info1 header formatter func LogInfo1(text string) { - fmt.Fprintln(os.Stdout, fmt.Sprintf("-----> %s", text)) + fmt.Println(fmt.Sprintf("-----> %s", text)) } // LogInfo1Quiet is the info1 header formatter (with quiet option) @@ -26,7 +26,7 @@ func LogInfo1Quiet(text string) { // LogInfo2 is the info2 header formatter func LogInfo2(text string) { - fmt.Fprintln(os.Stdout, fmt.Sprintf("=====> %s", text)) + fmt.Println(fmt.Sprintf("=====> %s", text)) } // LogInfo2Quiet is the info2 header formatter (with quiet option) @@ -39,7 +39,7 @@ func LogInfo2Quiet(text string) { // LogVerbose is the verbose log formatter // prints indented text to stdout func LogVerbose(text string) { - fmt.Fprintln(os.Stdout, fmt.Sprintf(" %s", text)) + fmt.Println(fmt.Sprintf(" %s", text)) } // LogVerboseQuiet is the verbose log formatter diff --git a/plugins/common/src/prop/prop.go b/plugins/common/src/prop/prop.go index 8614d9a0f..0a34a6ab3 100644 --- a/plugins/common/src/prop/prop.go +++ b/plugins/common/src/prop/prop.go @@ -68,7 +68,7 @@ func main() { property := flag.Arg(3) value := common.PropertyGet(pluginName, appName, property) if value != "" { - fmt.Printf("%v\n", value) + fmt.Println(value) } case "get-all": appName := flag.Arg(2) @@ -79,7 +79,7 @@ func main() { } for key, value := range values { - fmt.Fprintln(os.Stdout, key, strings.TrimSuffix(value, "\n")) + fmt.Println(fmt.Sprintf("%s %s", key, strings.TrimSuffix(value, "\n")) } case "get-with-default": appName := flag.Arg(2) @@ -87,19 +87,19 @@ func main() { defaultValue := flag.Arg(4) value := common.PropertyGetDefault(pluginName, appName, property, defaultValue) if value != "" { - fmt.Printf("%v\n", value) + fmt.Println(value) } case "lindex": appName := flag.Arg(2) property := flag.Arg(3) index := strToInt(flag.Arg(4), 0, false) - propertyValue, err := common.PropertyListGetByIndex(pluginName, appName, property, index) + value, err := common.PropertyListGetByIndex(pluginName, appName, property, index) if err != nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(1) } - fmt.Printf("%v\n", propertyValue) + fmt.Println(value) case "lismember": appName := flag.Arg(2) property := flag.Arg(3) @@ -118,7 +118,7 @@ func main() { os.Exit(1) } - fmt.Printf("%v\n", length) + fmt.Println(length) case "lrange": appName := flag.Arg(2) property := flag.Arg(3) @@ -129,7 +129,7 @@ func main() { } for _, line := range lines { - fmt.Printf("%v\n", line) + fmt.Println(line) } case "lrem": appName := flag.Arg(2) diff --git a/plugins/network/triggers.go b/plugins/network/triggers.go index 30b49d8b1..b9821dc8d 100644 --- a/plugins/network/triggers.go +++ b/plugins/network/triggers.go @@ -65,42 +65,42 @@ func TriggerNetworkComputePorts(appName string, processType string, isHerokuishC ports = append(ports, port) } } - fmt.Fprint(os.Stdout, strings.Join(ports, " ")) + fmt.Println(strings.Join(ports, " ")) } // TriggerNetworkConfigExists writes true or false to stdout whether a given app has network config func TriggerNetworkConfigExists(appName string) { if HasNetworkConfig(appName) { - fmt.Fprintln(os.Stdout, "true") + fmt.Println("true") return } - fmt.Fprintln(os.Stdout, "false") + fmt.Println("false") } // TriggerNetworkGetIppaddr writes the ipaddress to stdout for a given app container func TriggerNetworkGetIppaddr(appName string, processType string, containerID string) { ipAddress := GetContainerIpaddress(appName, processType, containerID) - fmt.Fprintln(os.Stdout, ipAddress) + fmt.Println(ipAddress) } // TriggerNetworkGetListeners returns the listeners (host:port combinations) for a given app container func TriggerNetworkGetListeners(appName string) { listeners := GetListeners(appName) - fmt.Fprint(os.Stdout, strings.Join(listeners, " ")) + fmt.Println(strings.Join(listeners, " ")) } // TriggerNetworkGetPort writes the port to stdout for a given app container func TriggerNetworkGetPort(appName string, processType string, isHerokuishContainer bool, containerID string) { port := GetContainerPort(appName, processType, isHerokuishContainer, containerID) - fmt.Fprintln(os.Stdout, port) + fmt.Println(port) } // TriggerNetworkGetProperty writes the network property to stdout for a given app container func TriggerNetworkGetProperty(appName string, property string) { defaultValue := GetDefaultValue(property) value := common.PropertyGetDefault("network", appName, property, defaultValue) - fmt.Fprintln(os.Stdout, value) + fmt.Println(value) } // TriggerNetworkWriteIpaddr writes the ip to disk diff --git a/plugins/resource/triggers.go b/plugins/resource/triggers.go index cf2dddb06..1714c8a6e 100644 --- a/plugins/resource/triggers.go +++ b/plugins/resource/triggers.go @@ -127,6 +127,6 @@ func TriggerResourceGetProperty(appName string, processType string, resourceType return err } - fmt.Fprintln(os.Stdout, value) + fmt.Println(value) return nil } From cff51b8ec9562251fda31fd60af793a52e8f2ffe Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 22 Feb 2020 04:59:53 -0500 Subject: [PATCH 2/2] fix: add missing parenthesis --- plugins/common/src/prop/prop.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/common/src/prop/prop.go b/plugins/common/src/prop/prop.go index 0a34a6ab3..c6ce2d0cf 100644 --- a/plugins/common/src/prop/prop.go +++ b/plugins/common/src/prop/prop.go @@ -79,7 +79,7 @@ func main() { } for key, value := range values { - fmt.Println(fmt.Sprintf("%s %s", key, strings.TrimSuffix(value, "\n")) + fmt.Println(fmt.Sprintf("%s %s", key, strings.TrimSuffix(value, "\n"))) } case "get-with-default": appName := flag.Arg(2)