Last active
September 19, 2017 15:57
-
-
Save masutaka/e07517b2c6f8c8694d2296d05cceed05 to your computer and use it in GitHub Desktop.
Maybe private method with golang
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 main | |
| import ( | |
| "fmt" | |
| ) | |
| func main() { | |
| fmt.Printf("main() in test.go\n") | |
| new(Test).Hoge() | |
| Test2.Hoge() | |
| Test2.aaa() // compile error | |
| } | |
| type Test struct{} | |
| func (t Test) Hoge() { | |
| fmt.Printf("Hoge() in test.go\n") | |
| } |
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 main | |
| import "fmt" | |
| type Test2Funcs interface { | |
| Hoge() | |
| } | |
| var Test2 Test2Funcs = test2Funcs{} | |
| type test2Funcs struct{} | |
| func (t test2Funcs) Hoge() { | |
| fmt.Printf("Hoge() in test2.go\n") | |
| } | |
| func (t test2Funcs) aaa() { | |
| fmt.Printf("aaa() in test2.go\n") | |
| } |
masutaka
commented
Sep 19, 2017
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment