Skip to content

Instantly share code, notes, and snippets.

@slawosz
Created September 23, 2014 13:17
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 slawosz/ed427b83fe7501d67c15 to your computer and use it in GitHub Desktop.
Save slawosz/ed427b83fe7501d67c15 to your computer and use it in GitHub Desktop.
package main
import "fmt"
type Foo struct {
Payload string
}
type Bar struct {
Foo
}
func (f *Foo) DoStuff(arg string) {
f.Payload = arg
}
func main() {
f := &Bar{Foo{"1234"}}
f.DoStuff("4321")
fmt.Println(f)
}
package main
import "fmt"
func call(f func(string)) { f("foo") }
type Foo struct {
Payload string
}
func (f Foo) foo(str string) {
fmt.Println(f.Payload, str)
}
func main() {
f1 := Foo{"foo1"}
f2 := Foo{"foo2"}
call(f1.foo)
call(f2.foo)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment