Golang 结构体 参数类型为 函数 简单实例

package main

import "fmt"

//定义一个类型
type tsh struct {
	//定义成员,类型是func() string
	test func() string
}

func main() {
	t := tsh{
		test: func() string {
			return "123"
		},
	}
	fmt.Println(t.test())
}

  

posted @ 2021-01-23 14:43  Black_Climber  阅读(248)  评论(0编辑  收藏  举报