Skip to content

Instantly share code, notes, and snippets.

@swshan
Created June 3, 2017 04:06
Show Gist options
  • Save swshan/dc377d80bbb57d76aa5ed2fc46a4101d to your computer and use it in GitHub Desktop.
Save swshan/dc377d80bbb57d76aa5ed2fc46a4101d to your computer and use it in GitHub Desktop.
// 来自 http://xinqiu.me/2017/05/09/a-byte-of-go/ 的练习代码
package main
import "fmt"
func main() {
s := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
a := s[3:6]
b := a[1:2]
printSlice(a)
printSlice(b)
}
func printSlice(s []int) {
fmt.Printf("len=%d cap=%d %v\n", len(s), cap(s), s)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment