aboutsummaryrefslogtreecommitdiff
path: root/content/constants/float2.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2014-08-25 11:43:57 +1000
committerAndrew Gerrand <adg@golang.org>2014-08-25 11:43:57 +1000
commit01eb87f06aa87b7a2d11b8031f51649ba60375aa (patch)
tree1474aa10af024ca9cecf1251a92b1b6bcf30e461 /content/constants/float2.go
parentf953585a9d3c25fcc30e6a0a3d26a0a70de73bcd (diff)
go.blog: constants
LGTM=gri, adg, rsc R=gri, adg, rsc CC=golang-codereviews https://golang.org/cl/125540043
Diffstat (limited to 'content/constants/float2.go')
-rw-r--r--content/constants/float2.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/content/constants/float2.go b/content/constants/float2.go
new file mode 100644
index 0000000..f43feb6
--- /dev/null
+++ b/content/constants/float2.go
@@ -0,0 +1,17 @@
+// +build OMIT
+
+package main
+
+import "fmt"
+
+func main() {
+ const Zero = 0.0
+ const TypedZero float64 = 0.0
+ // START OMIT
+ var f32 float32
+ f32 = 0.0
+ f32 = Zero // OK: Zero is untyped
+ f32 = TypedZero // Bad: TypedZero is float64 not float32.
+ fmt.Println(f32)
+ // STOP OMIT
+}