Skip to content

Instantly share code, notes, and snippets.

@hyper0x
Created July 21, 2015 02:40
Show Gist options
  • Save hyper0x/d8b26118d766c984d1b5 to your computer and use it in GitHub Desktop.
Save hyper0x/d8b26118d766c984d1b5 to your computer and use it in GitHub Desktop.
package main
import "fmt"
type Person struct {
name string
}
type Dept struct {
persons [4]Person
}
func main() {
ch := make(chan Dept, 1)
persons := [4]Person{}
persons[0] = Person{"Robert"}
d1 := Dept{persons}
fmt.Printf("Dept1:\t\t%#v\n", d1)
ch <- d1
d1Copy := <-ch
d1.persons[0].name = "Michael"
fmt.Printf("Dept1(2):\t%#v\n", d1)
fmt.Printf("Dept1 copy:\t%#v\n", d1Copy)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment