• Rob Pike's avatar
    fmt: only use Stringer or Error for strings · 2ed57a8c
    Rob Pike authored
    This is a slight change to fmt's semantics, but means that if you use
    %d to print an integer with a Stringable value, it will print as an integer.
    This came up because Time.Month() couldn't cleanly print as an integer
    rather than a name. Using %d on Stringables is silly anyway, so there
    should be no effect outside the fmt tests.
    As a mild bonus, certain recursive failures of String methods
    will also be avoided this way.
    
    R=golang-dev, adg
    CC=golang-dev
    https://golang.org/cl/5453053
    2ed57a8c
print.go 26.5 KB