mirror of
https://github.com/traefik/yaegi.git
synced 2026-06-01 18:37:56 +00:00
It allows to use interpreter functions as parameters in the runtime, even for defered callbacks, or when passed as empty interfaces, as for runtime.SetFinalizer. Fixes #1503
26 lines
260 B
Go
26 lines
260 B
Go
package main
|
|
|
|
import (
|
|
"runtime"
|
|
)
|
|
|
|
type T struct {
|
|
name string
|
|
}
|
|
|
|
func finalize(t *T) { println("finalize") }
|
|
|
|
func newT() *T {
|
|
t := new(T)
|
|
runtime.SetFinalizer(t, finalize)
|
|
return t
|
|
}
|
|
|
|
func main() {
|
|
t := newT()
|
|
println(t != nil)
|
|
}
|
|
|
|
// Output:
|
|
// true
|