From 01eb87f06aa87b7a2d11b8031f51649ba60375aa Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Mon, 25 Aug 2014 11:43:57 +1000 Subject: go.blog: constants LGTM=gri, adg, rsc R=gri, adg, rsc CC=golang-codereviews https://golang.org/cl/125540043 --- content/constants/float2.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 content/constants/float2.go (limited to 'content/constants/float2.go') 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 +} -- cgit v1.2.3