Skip to content

Instantly share code, notes, and snippets.

@J7mbo
Created February 22, 2019 12:09
Show Gist options
  • Save J7mbo/96dc3d8c277a5bf83b75b0c89f3e9be3 to your computer and use it in GitHub Desktop.
Save J7mbo/96dc3d8c277a5bf83b75b0c89f3e9be3 to your computer and use it in GitHub Desktop.
golang-constructors-blog-7
type MyStruct struct {
child *ChildStruct
}
func (s MyStruct) StructFunc() {
/* Here's where things go wrong */
fmt.Println(s.child.num)
}
type ChildStruct struct {
num int
}
func DoSomething(obj MyStruct) {
obj.StructFunc()
}
DoSomething(MyStruct{})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment