From 758ff64c69e34965f8af5b2d6ffd65e8d7ab2150 Mon Sep 17 00:00:00 2001 From: Ondřej Surý Date: Mon, 14 Feb 2011 13:23:51 +0100 Subject: Imported Upstream version 2011-02-01.1 --- doc/go_faq.html | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'doc/go_faq.html') diff --git a/doc/go_faq.html b/doc/go_faq.html index 1c7b85ef8..3f9c1d246 100644 --- a/doc/go_faq.html +++ b/doc/go_faq.html @@ -665,11 +665,16 @@ of Effective Go for more details. Why is int 32 bits on 64 bit machines?

-The size of int and float is implementation-specific. +The sizes of int and uint are implementation-specific +but the same as each other on a given platform. The 64 bit Go compilers (both 6g and gccgo) use a 32 bit representation for -both int and float. Code that relies on a particular -size of value should use an explicitly sized type, like int64 or -float64. +int. Code that relies on a particular +size of value should use an explicitly sized type, like int64. +On the other hand, floating-point scalars and complex +numbers are always sized: float32, complex64, +etc., because programmers should be aware of precision when using +floating-point numbers. +The default size of a floating-point constant is float64.

Concurrency

@@ -788,7 +793,7 @@ Consider the following program: func main() { done := make(chan bool) - values = []string{ "a", "b", "c" } + values := []string{ "a", "b", "c" } for _, v := range values { go func() { fmt.Println(v) @@ -797,7 +802,7 @@ func main() { } // wait for all goroutines to complete before exiting - for i := range values { + for _ = range values { <-done } } @@ -818,7 +823,7 @@ could modify the inner loop to read:
 	for _, v := range values {
-		go func(u) {
+		go func(u string) {
 			fmt.Println(u)
 			done <- true
 		}(v)
-- 
cgit v1.2.3