【发布时间】:2013-05-26 22:33:54
【问题描述】:
package main
import "fmt"
type fake struct {
}
func main() {
f := func() interface{} {
return &fake{}
}
one := f()
two := f()
fmt.Println("Are equal?: ", one == two)
fmt.Printf("%p", one)
fmt.Println()
fmt.Printf("%p", two)
fmt.Println()
}
(http://play.golang.org/p/wxCUUCyz98)
为什么这个匿名函数返回请求类型的相同实例,我怎样才能让它在每次调用时返回一个新实例?
【问题讨论】:
标签: go