-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
https://go.dev/play/p/DwZgPX8HhBs
package main
import (
"fmt"
"golang.design/x/reflect"
)
type ListNode struct {
Val int
Next *ListNode
}
func main() {
n := ListNode{Val: 1}
n2 := reflect.DeepCopy(n)
fmt.Printf("%+v %+v\n", n, n2)
fmt.Println(n2.Next.Val) // 0
}n.Next is nil, but becomes &ListNode{} after the deep copy.
changkun