How to access slice items in Golang?
You access the slice items by referring to the index number.
Example
package main
import "fmt"
func main() {
var intSlice = []int{10, 20, 30, 40}
fmt.Println(intSlice[0])
fmt.Println(intSlice[1])
fmt.Println(intSlice[0:4])
}
Most Helpful This Week
Panic: runtime error: index out of range error in Golang
Golang program for implementation of Random Maze Generator
How to build a map of struct and append values to it?
Invalid operation: <variable> (type <type>) does not support indexing error in Golang
Golang program for implementation of Insertion Sort
How do you send an HTTP PUT request in Go?