/*
  go函数回调
  go支持函数回调 你可以把函数名称作为参数传递给另外一个函数
  然后在别的地方实现这个函数
*/

package main

import (
    "fmt"
)

/*
   知识点:
   type xxx 基础类型
   给基础类型起别名
*/

type Callback func(x, y int) int

func main() {
    x, y := 1, 2
    fmt.Println(test(x, y, add))
}

func test(x, y int, callback Callback) int {
    return callback(x, y)
}

func add(x, y int) int {
    return x + y
}