code review 8638043: fmt: tweak the explanation of Stringer to be more corre... (issue 8638043)

63 views
Skip to first unread message

r...@golang.org

unread,
Apr 10, 2013, 4:44:35 PM4/10/13
to golan...@googlegroups.com, re...@codereview-hr.appspotmail.com
Reviewers: golang-dev1,

Message:
Hello golan...@googlegroups.com,

I'd like you to review this change to
https://code.google.com/p/go/


Description:
fmt: tweak the explanation of Stringer to be more correct and less
specific
The String method is called whenever the printing operation wants a
string,
not just for %s and %v.

Please review this at https://codereview.appspot.com/8638043/

Affected files:
src/pkg/fmt/print.go


Index: src/pkg/fmt/print.go
===================================================================
--- a/src/pkg/fmt/print.go
+++ b/src/pkg/fmt/print.go
@@ -56,7 +56,8 @@
// Stringer is implemented by any value that has a String method,
// which defines the ``native'' format for that value.
// The String method is used to print values passed as an operand
-// to a %s or %v format or to an unformatted printer such as Print.
+// to any format that accepts a string or to an unformatted printer
+// such as Print.
type Stringer interface {
String() string
}


Brad Fitzpatrick

unread,
Apr 10, 2013, 4:57:43 PM4/10/13
to Rob Pike, golang-dev, re...@codereview-hr.appspotmail.com
LGTM






--

---You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



r...@golang.org

unread,
Apr 10, 2013, 5:05:37 PM4/10/13
to r...@golang.org, golan...@googlegroups.com, brad...@golang.org, re...@codereview-hr.appspotmail.com
*** Submitted as
https://code.google.com/p/go/source/detail?r=522c34c6fe61 ***

fmt: tweak the explanation of Stringer to be more correct and less
specific
The String method is called whenever the printing operation wants a
string,
not just for %s and %v.

R=golang-dev, bradfitz
CC=golang-dev
https://codereview.appspot.com/8638043


https://codereview.appspot.com/8638043/

r.ekl...@gmail.com

unread,
Apr 12, 2013, 11:31:07 PM4/12/13
to r...@golang.org, golan...@googlegroups.com, brad...@golang.org, re...@codereview-hr.appspotmail.com
Clarification of the Formatter comment required.


https://codereview.appspot.com/8638043/diff/3002/src/pkg/fmt/print.go
File src/pkg/fmt/print.go (right):

https://codereview.appspot.com/8638043/diff/3002/src/pkg/fmt/print.go#newcode50
src/pkg/fmt/print.go:50: // The implementation of Format may call
Sprint(f) or Fprint(f) etc.
In this case does f represent the a Formatter or a State? Sprint accepts
a Formatter as the first argument while Fprint accepts a State.

Example:
http://play.golang.org/p/hrStktWIcq

prog.go:14: cannot use f (type F) as type io.Writer in function
argument:
F does not implement io.Writer (missing Write method)

https://codereview.appspot.com/8638043/

Rob Pike

unread,
Apr 13, 2013, 1:32:42 AM4/13/13
to r...@golang.org, r.ekl...@gmail.com, golan...@googlegroups.com, brad...@golang.org, re...@codereview-hr.appspotmail.com
It's shorthand for Sprint or Sprintf, etc.

-rob
Reply all
Reply to author
Forward
0 new messages