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
Golang program to read XML file into struct
What is Slice Data Type in Go?
What is an HTTP server in Go?
Program in Go language to Find Largest Element of an Array
Empty Interface Type in Go Programming Language
Program in Golang to print Pyramid of Numbers
Illustration of Cigarette Smokers Problem in Golang
Read and Write Fibonacci series to Channel in Golang
Golang panic recover example
Use Field Tags in the Definition of Struct Type