github.com/spotify/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/blog/content/slices/prog090.go (about) 1 // Copyright 2013 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import ( 8 "fmt" 9 ) 10 11 func main() { 12 slice := make([]int, 10, 15) 13 fmt.Printf("len: %d, cap: %d\n", len(slice), cap(slice)) 14 newSlice := make([]int, len(slice), 2*cap(slice)) 15 copy(newSlice, slice) 16 slice = newSlice 17 fmt.Printf("len: %d, cap: %d\n", len(slice), cap(slice)) 18 }