Skip to content

Instantly share code, notes, and snippets.

@macu
Last active January 3, 2016 19:39
Show Gist options
  • Select an option

  • Save macu/8510328 to your computer and use it in GitHub Desktop.

Select an option

Save macu/8510328 to your computer and use it in GitHub Desktop.
Some findings of interest about the Go language.
if f, ok := x.(interface { Foo() }); ok {
f.Foo()
}
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