Исходники и презентации
This commit is contained in:
18
lessons/garbage_collector/weak_ptr/main.go
Normal file
18
lessons/garbage_collector/weak_ptr/main.go
Normal file
@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"time"
|
||||
"weak"
|
||||
)
|
||||
|
||||
func main() {
|
||||
pointer := new(string)
|
||||
weakPtr := weak.Make(pointer)
|
||||
|
||||
runtime.GC()
|
||||
time.Sleep(time.Second)
|
||||
|
||||
fmt.Println(weakPtr.Value() == nil)
|
||||
}
|
||||
Reference in New Issue
Block a user