Source file tour/moretypes/slices-pointers.go

     1  //go:build OMIT
     2  
     3  package main
     4  
     5  import "fmt"
     6  
     7  func main() {
     8  	names := [4]string{
     9  		"John",
    10  		"Paul",
    11  		"George",
    12  		"Ringo",
    13  	}
    14  	fmt.Println(names)
    15  
    16  	a := names[0:2]
    17  	b := names[1:3]
    18  	fmt.Println(a, b)
    19  
    20  	b[0] = "XXX"
    21  	fmt.Println(a, b)
    22  	fmt.Println(names)
    23  }
    24  

View as plain text