How the go language enforces the use of value replication to assign values instead of just letting pointers point to the same value

when you assign a variable of pointer type to a new variable, just pass an address, two variables actually point to the same object, change one, that is, change both.

package main

import (
    "container/list"
    "fmt"
)

func main() {
    l1 := list.New() // *list.List
    l1.PushBack(1)
    fmt.Println(l1.Back().Value) // 1

    l2 := l1
    l2.PushBack(2)
    fmt.Println(l1.Back().Value, l2.Back().Value) // 2 2

    l1.PushBack(3)
    fmt.Println(l1.Back().Value, l2.Back().Value) // 3 3
}

is there any simple way to make a pointer type assignment like a value type assignment, make a copy of the value and pass it back?

Mar.18,2021

package main

import (
    "container/list"
    "fmt"
)

func main() {
    l1 := list.New()
    l1.PushBack(1)
    fmt.Println(l1.Back().Value)

    l2 := *l1
    l2.PushBack(2)
    fmt.Println(l1.Back().Value, l2.Back().Value)
}

output

1
2 1
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4c9a7-43e40.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4c9a7-43e40.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?