Created
February 22, 2019 12:09
-
-
Save J7mbo/96dc3d8c277a5bf83b75b0c89f3e9be3 to your computer and use it in GitHub Desktop.
golang-constructors-blog-7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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