From a4747888559e262b09b1037c75cd47c5d512b742 Mon Sep 17 00:00:00 2001 From: Andy Chen Date: Wed, 15 Mar 2017 16:47:00 -0700 Subject: [PATCH 1/2] Update func Sprint declaring `s` in return --- src/fmt/print.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fmt/print.go b/src/fmt/print.go index 2bd88f95a2b80a..dcfeecc4476c24 100644 --- a/src/fmt/print.go +++ b/src/fmt/print.go @@ -227,12 +227,12 @@ func Print(a ...interface{}) (n int, err error) { // Sprint formats using the default formats for its operands and returns the resulting string. // Spaces are added between operands when neither is a string. -func Sprint(a ...interface{}) string { +func Sprint(a ...interface{}) (s string) { p := newPrinter() p.doPrint(a) - s := string(p.buf) + s = string(p.buf) p.free() - return s + return } // These routines end in 'ln', do not take a format string, From 4091fd8e04c1aab8e3f6ebb56cf1b1e53d534f42 Mon Sep 17 00:00:00 2001 From: Andy Chen Date: Wed, 15 Mar 2017 16:49:21 -0700 Subject: [PATCH 2/2] Update Sprintln and Springf --- src/fmt/print.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/fmt/print.go b/src/fmt/print.go index dcfeecc4476c24..760b8d1e6f1dc4 100644 --- a/src/fmt/print.go +++ b/src/fmt/print.go @@ -191,12 +191,12 @@ func Printf(format string, a ...interface{}) (n int, err error) { } // Sprintf formats according to a format specifier and returns the resulting string. -func Sprintf(format string, a ...interface{}) string { +func Sprintf(format string, a ...interface{}) (s string) { p := newPrinter() p.doPrintf(format, a) - s := string(p.buf) + s = string(p.buf) p.free() - return s + return } // Errorf formats according to a format specifier and returns the string @@ -259,12 +259,12 @@ func Println(a ...interface{}) (n int, err error) { // Sprintln formats using the default formats for its operands and returns the resulting string. // Spaces are always added between operands and a newline is appended. -func Sprintln(a ...interface{}) string { +func Sprintln(a ...interface{}) (s string) { p := newPrinter() p.doPrintln(a) - s := string(p.buf) + s = string(p.buf) p.free() - return s + return } // getField gets the i'th field of the struct value.