Last active
January 3, 2016 19:39
-
-
Save macu/8510328 to your computer and use it in GitHub Desktop.
Some findings of interest about the Go language.
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
| if f, ok := x.(interface { Foo() }); ok { | |
| f.Foo() | |
| } |
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 A struct{ name string } | |
| func (a A) Print() { fmt.Println(a.name) } | |
| func main() { | |
| var a = A{"test"} | |
| a.Print() | |
| A.Print(a) // invoke static method with receiver as first argument, may be nil | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment