diff options
author | Dave Brophy <dave@brophy.uk> | 2018-08-28 18:13:40 +0000 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2018-08-28 20:15:15 +0000 |
commit | 7c7cecc1846aaaa0ce73931644fe1df2b4559e09 (patch) | |
tree | b600b7702a813600bf4634734ae3ea93c8b38e25 /test/switch5.go | |
parent | cb7f9ec4b71e81760fa36ebff60a7e41a07df238 (diff) | |
download | go-7c7cecc1846aaaa0ce73931644fe1df2b4559e09.tar.gz go-7c7cecc1846aaaa0ce73931644fe1df2b4559e09.zip |
fmt: fix incorrect format of whole-number floats when using %#v
This fixes the unwanted behaviour where printing a zero float with the
#v fmt verb outputs "0" - e.g. missing the trailing decimal. This means
that the output would be interpreted as an int rather than a float when
parsed as Go source. After this change the the output is "0.0".
Fixes #26363
Change-Id: Ic5c060522459cd5ce077675d47c848b22ddc34fa
GitHub-Last-Rev: adfb061363f0566acec134c81be9a3dcb1f4cac8
GitHub-Pull-Request: golang/go#26383
Reviewed-on: https://go-review.googlesource.com/123956
Reviewed-by: Daniel Martà <mvdan@mvdan.cc>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Daniel Martà <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'test/switch5.go')
-rw-r--r-- | test/switch5.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/switch5.go b/test/switch5.go index ce95bf8d7b..6641d582bc 100644 --- a/test/switch5.go +++ b/test/switch5.go @@ -24,8 +24,8 @@ func f0(x int) { func f1(x float32) { switch x { case 5: - case 5: // ERROR "duplicate case 5 in switch" - case 5.0: // ERROR "duplicate case 5 in switch" + case 5: // ERROR "duplicate case 5 .value 5\.0. in switch" + case 5.0: // ERROR "duplicate case 5 .value 5\.0. in switch" } } @@ -44,9 +44,9 @@ func f3(e interface{}) { case 0: // ERROR "duplicate case 0 in switch" case int64(0): case float32(10): - case float32(10): // ERROR "duplicate case float32\(10\) .value 10. in switch" + case float32(10): // ERROR "duplicate case float32\(10\) .value 10\.0. in switch" case float64(10): - case float64(10): // ERROR "duplicate case float64\(10\) .value 10. in switch" + case float64(10): // ERROR "duplicate case float64\(10\) .value 10\.0. in switch" } } |