1
0
mirror of https://github.com/chai2010/advanced-go-programming-book.git synced 2025-05-23 20:02:22 +00:00

ch3.6.6: 修复函数返回值

This commit is contained in:
chai2010 2018-12-27 21:05:41 +08:00
parent e4451a801b
commit 16a588e572
2 changed files with 2 additions and 2 deletions

View File

@ -352,7 +352,7 @@ func NewTwiceFunClosure(x int) func() int {
func ptrToFunc(p unsafe.Pointer) func() int
func asmFunTwiceClosureAddr() uintptr
func asmFunTwiceClosureBody()
func asmFunTwiceClosureBody() int
```
其中`ptrToFunc`用于将指针转化为`func() int`类型的闭包函数,`asmFunTwiceClosureAddr`用于返回闭包函数机器指令的开始地址(类似全局函数的地址),`asmFunTwiceClosureBody`是闭包函数对应的全局函数的实现。

View File

@ -23,7 +23,7 @@ func NewTwiceFunClosure(x int) func() int {
func ptrToFunc(p unsafe.Pointer) func() int
func asmFunTwiceClosureAddr() uintptr
func asmFunTwiceClosureBody()
func asmFunTwiceClosureBody() int
func main() {
fnTwice := NewTwiceFunClosure(1)