ref: 10dd31bf9cab0052c47987ee5900d32cb689277b a-tour-of-go/basics/structs-slices-maps/1.3.10_slice-bounds.go -rw-r--r-- 288 bytes View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
	Notes 1.3.10

	- You can omit the low/high bound from a slice to use the defaults
*/

package main

import "fmt"

func main() {
	s := []int{2, 3, 5, 7, 11, 13}

	s = s[1:4]	// 3, 5, 7
	fmt.Println(s)

	s = s[:2]	// 2, 3
	fmt.Println(s)

	s = s[1:]	// 3, 5, 7, 11, 13
	fmt.Println(s)
}