Skip to content

Instantly share code, notes, and snippets.

@satoryu
Created May 24, 2019 09:35
Show Gist options
  • Save satoryu/362525f573f5dfafbdd6c82c9e5e273b to your computer and use it in GitHub Desktop.
Save satoryu/362525f573f5dfafbdd6c82c9e5e273b to your computer and use it in GitHub Desktop.
package main
import "fmt"
type Person struct {
Name string
}
func (p Person) Greeting() string {
return fmt.Sprintf("Hello, %v!", p.Name)
}
type Echoable func() string
func Echo(f Echoable) {
fmt.Println(f())
}
func main() {
p := Person{"Satoryu"}
var f Echoable
f = p.Greeting
Echo(f)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment