Created
February 22, 2019 12:07
-
-
Save J7mbo/3c392f43616030e1e5e9fc568fd5ffd8 to your computer and use it in GitHub Desktop.
golang-constructors-blog-6
This file contains hidden or 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
package Package1 | |
/* The interface is exported, so publically available */ | |
type MyStructsInterface interface { | |
SomeInterfaceMethod() int | |
} | |
/* Private struct */ | |
type myStruct struct { | |
num int | |
} | |
func NewMyStruct() myStruct { | |
return MyStruct{num: 22} | |
} | |
/* With this, myStruct now implicitly implements MyStructsInterface */ | |
func (*myStruct) SomeInterfaceMethod() int { | |
return 42 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment