From c50074e5104563d23455a27ece2430bef2d4c844 Mon Sep 17 00:00:00 2001
From: Stefan Nilsson tags
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5707065
---
doc/code.html | 2 +-
doc/effective_go.html | 9 +++++++++
doc/effective_go.tmpl | 9 +++++++++
doc/go_faq.html | 2 ++
doc/go_spec.html | 3 ++-
5 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/doc/code.html b/doc/code.html
index 5ae57075ed..625a98c1f1 100644
--- a/doc/code.html
+++ b/doc/code.html
@@ -323,7 +323,7 @@ foo_amd64.go
foo_arm.go
-describes a package that builds on
+ describes a package that builds on
different architectures by parameterizing the file name with
$GOARCH.append built-in function. The signature of append
is different from our custom Append function above.
Schematically, it's like this:
+
func append(slice []T, elements...T) []T+
where T is a placeholder for any given type. You can't
actually write a function in Go where the type T
is determined by the caller.
That's why append is built in: it needs support from the
compiler.
+
What append does is append the elements to the end of
the slice and return the result. The result needs to be returned
because, as with our hand-written Append, the underlying
array may change. This simple example
+
x := []int{1,2,3}
x = append(x, 4, 5, 6)
fmt.Println(x)
+
prints [1 2 3 4 5 6]. So append works a
little like Printf, collecting an arbitrary number of
arguments.
+
But what if we wanted to do what our Append does and
append a slice to a slice? Easy: use ... at the call
site, just as we did in the call to Output above. This
snippet produces identical output to the one above.
+
x := []int{1,2,3}
y := []int{4,5,6}
x = append(x, y...)
fmt.Println(x)
+
Without that ..., it wouldn't compile because the types
would be wrong; y is not of type int.
+
append built-in function. The signature of append
is different from our custom Append function above.
Schematically, it's like this:
+
func append(slice []T, elements...T) []T+
where T is a placeholder for any given type. You can't
actually write a function in Go where the type T
is determined by the caller.
That's why append is built in: it needs support from the
compiler.
+
What append does is append the elements to the end of
the slice and return the result. The result needs to be returned
because, as with our hand-written Append, the underlying
array may change. This simple example
+
x := []int{1,2,3}
x = append(x, 4, 5, 6)
fmt.Println(x)
+
prints [1 2 3 4 5 6]. So append works a
little like Printf, collecting an arbitrary number of
arguments.
+
But what if we wanted to do what our Append does and
append a slice to a slice? Easy: use ... at the call
site, just as we did in the call to Output above. This
snippet produces identical output to the one above.
+
x := []int{1,2,3}
y := []int{4,5,6}
x = append(x, y...)
fmt.Println(x)
+
Without that ..., it wouldn't compile because the types
would be wrong; y is not of type int.
+
:= so
var a uint64 = 1
+has the same effect as +
a := uint64(1)
diff --git a/doc/go_spec.html b/doc/go_spec.html
index ae0a4616a7..1be629146f 100644
--- a/doc/go_spec.html
+++ b/doc/go_spec.html
@@ -696,10 +696,11 @@ using a receiver of that type.
A boolean type represents the set of Boolean truth values
denoted by the predeclared constants true
and false. The predeclared boolean type is bool.
-
+