summaryrefslogtreecommitdiff
path: root/doc/go_faq.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/go_faq.html')
-rw-r--r--doc/go_faq.html19
1 files changed, 12 insertions, 7 deletions
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</a> for more details.
Why is <code>int</code> 32 bits on 64 bit machines?</h3>
<p>
-The size of <code>int</code> and <code>float</code> is implementation-specific.
+The sizes of <code>int</code> and <code>uint</code> 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 <code>int</code> and <code>float</code>. Code that relies on a particular
-size of value should use an explicitly sized type, like <code>int64</code> or
-<code>float64</code>.
+<code>int</code>. Code that relies on a particular
+size of value should use an explicitly sized type, like <code>int64</code>.
+On the other hand, floating-point scalars and complex
+numbers are always sized: <code>float32</code>, <code>complex64</code>,
+etc., because programmers should be aware of precision when using
+floating-point numbers.
+The default size of a floating-point constant is <code>float64</code>.
</p>
<h2 id="Concurrency">Concurrency</h2>
@@ -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 {
&lt;-done
}
}
@@ -818,7 +823,7 @@ could modify the inner loop to read:
<pre>
for _, v := range values {
- go func(<b>u</b>) {
+ go func(<b>u</b> string) {
fmt.Println(<b>u</b>)
done &lt;- true
}(<b>v</b>)