ref: b10fb217bb6c0e0a4214a8d1e71e504481c0a13e a-tour-of-go/basics/structs-slices-maps/1.3.10_slice-bounds.go -rw-r--r-- 274 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]	// 3, 5
	fmt.Println(s)

	s = s[1:]	// 5
	fmt.Println(s)
}