| // +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. |
| |
| package main |
| |
| import ( |
| "fmt" |
| ) |
| |
| func main() { |
| // START OMIT |
| // Create a couple of starter slices. |
| slice := []int{1, 2, 3} |
| slice2 := []int{55, 66, 77} |
| fmt.Println("Start slice: ", slice) |
| fmt.Println("Start slice2:", slice2) |
| |
| // Add an item to a slice. |
| slice = append(slice, 4) |
| fmt.Println("Add one item:", slice) |
| |
| // Add one slice to another. |
| slice = append(slice, slice2...) |
| fmt.Println("Add one slice:", slice) |
| |
| // Make a copy of a slice (of int). |
| slice3 := append([]int(nil), slice...) |
| fmt.Println("Copy a slice:", slice3) |
| |
| // Copy a slice to the end of itself. |
| fmt.Println("Before append to self:", slice) |
| slice = append(slice, slice...) |
| fmt.Println("After append to self:", slice) |
| // END OMIT |
| } |