Skip to content

Instantly share code, notes, and snippets.

@mauricio
Created July 23, 2013 02:55
Show Gist options
  • Select an option

  • Save mauricio/6059516 to your computer and use it in GitHub Desktop.

Select an option

Save mauricio/6059516 to your computer and use it in GitHub Desktop.
0 - John - 10
1 - moe - 15
2 - homer - 40
people2 array
0 - John - 10
1 - moe - 15
2 - Bart - 40
package main
import "fmt"
type Person struct {
Name string
Age int
}
func main() {
people := [3]Person{{"John", 10}, {"moe", 15},{"homer", 40}}
people2 := people
people2[2].Name = "Bart"
fmt.Println("people array")
for index,element := range people {
fmt.Printf("%d - %s - %d\n", index, element.Name, element.Age)
}
fmt.Println("")
fmt.Println("people2 array")
for index,element := range people2 {
fmt.Printf("%d - %s - %d\n", index, element.Name, element.Age)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment