1
0
mirror of https://github.com/golang/go synced 2024-10-04 10:31:22 -06:00
Commit Graph

4 Commits

Author SHA1 Message Date
Russ Cox
f2b5a07453 delete float, complex - code changes
also:
	cmplx -> complex
	float64(1.0) -> 1.0
	float64(1) -> 1.0

R=gri, r, gri1, r2
CC=golang-dev
https://golang.org/cl/3991043
2011-01-19 23:09:00 -05:00
Rob Pike
d482c163be fmt.Print*: reimplement to switch on type first.
This shortens, simplifies and regularizes the code significantly.
(Improvements to reflect could make another step.)
Passes all.bash.

One semantic change occurs: The String() method changes
behavior. It used to run only for string formats such as %s and %q.
Instead, it now runs whenever the item has the method and the
result is then processed by the format as a string. Besides the
regularization, this has three effects:

	1) width is honored for String() items
	2) %x works for String() items
	3) implementations of String that merely recur will recur forever

Regarding point 3, example from the updated documentation:
	type X int
	func (x X) String() string { return Sprintf("%d", x) }
should cast the value before recurring:
	func (x X) String() string { return Sprintf("%d", int(x)) }

R=rsc
CC=golang-dev
https://golang.org/cl/1613045
2010-06-14 17:16:35 -07:00
Rob Pike
24ee7f799c %q in fmt: if the object is a Stringer, use String() to get the value to quote.
R=rsc
CC=golang-dev
https://golang.org/cl/224051
2010-02-25 17:29:37 +11:00
Ian Lance Taylor
115066fd14 Fix printing of named floating point types.
Try to avoid infinite recursion if String fails due to
printing a bad type.

Add test for String method with named basic types.

R=r
CC=golang-dev
https://golang.org/cl/207102
2010-02-15 22:42:49 -08:00