// +build OMIT// Copyright 2013 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.packagemainimport("fmt")// Append appends the elements to the slice.// Efficient version.funcAppend(slice[]int,elements...int)[]int{n:=len(slice)total:=len(slice)+len(elements)iftotal>cap(slice){// Reallocate. Grow to 1.5 times the new size, so we can still grow.newSize:=total*3/2+1newSlice:=make([]int,total,newSize)copy(newSlice,slice)slice=newSlice}slice=slice[:total]copy(slice[n:],elements)returnslice}funcmain(){// START OMITslice1:=[]int{0,1,2,3,4}slice2:=[]int{55,66,77}fmt.Println(slice1)slice1=Append(slice1,slice2...)// The '...' is essential!fmt.Println(slice1)// END OMIT}