Commit bb195f67 authored by Rob Pike's avatar Rob Pike

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://golang.org/cl/8638043
parent d06313e8
...@@ -47,7 +47,7 @@ type State interface { ...@@ -47,7 +47,7 @@ type State interface {
} }
// Formatter is the interface implemented by values with a custom formatter. // Formatter is the interface implemented by values with a custom formatter.
// The implementation of Format may call Sprintf or Fprintf(f) etc. // The implementation of Format may call Sprint(f) or Fprint(f) etc.
// to generate its output. // to generate its output.
type Formatter interface { type Formatter interface {
Format(f State, c rune) Format(f State, c rune)
...@@ -56,7 +56,8 @@ type Formatter interface { ...@@ -56,7 +56,8 @@ type Formatter interface {
// Stringer is implemented by any value that has a String method, // Stringer is implemented by any value that has a String method,
// which defines the ``native'' format for that value. // which defines the ``native'' format for that value.
// The String method is used to print values passed as an operand // 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 { type Stringer interface {
String() string String() string
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment