Skip to content

Instantly share code, notes, and snippets.

@hutch
Created June 27, 2012 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hutch/3005930 to your computer and use it in GitHub Desktop.
Save hutch/3005930 to your computer and use it in GitHub Desktop.
Follow up to "A Rubyist has Some Difficulties with Go"
package main
import "fmt"
type A struct{}
func (A) Name() { fmt.Println("A") }
func (self A) SomeAMethod() {
self.Name()
self.Name()
}
type B struct {
A
}
func (B) Name() { fmt.Println("B") }
type WithName interface {
Name()
}
func main() {
v := new(B)
fmt.Printf("v is %+v\n", v)
v.Name()
// These next two lines do exactly the same thing
v.SomeAMethod()
v.A.SomeAMethod()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment