当前位置:网站首页>Go language shallow copy and deep copy
Go language shallow copy and deep copy
2022-06-26 07:59:00 【mq-shao】
- Deep copy : Copy the data , Two variables have different addresses , After copying, the operation of the two variables does not affect each other
- Shallow copy : Copy address , After the copy, the operation of the two variables affects each other , Modification of one variable will affect another variable
package main
import (
"fmt"
)
func main() {
var src []int
src = []int{1, 2, 3}
fmt.Println(" Initial value src : ", src)
fmt.Println("---------------------")
des1 := src
des2 := make([]int, len(src))
copy(des2, src)
fmt.Println(" Shallow copy des1: ", des1)
fmt.Println(" Deep copy des2: ", des2)
fmt.Println("---------------------")
src[1] = 0
fmt.Println(" modify src : ", src)
fmt.Println("des1: ", des1)
fmt.Println("des2: ", des2)
}
边栏推荐
- Bluebridge cup 1 introduction training Fibonacci series
- 2: String insert
- Encapsulating ranging and surface class based on leaflet
- Google Earth engine (GEE) 02 basic knowledge and learning resources
- PyTorch-12 GAN、WGAN
- Google Earth Engine(GEE) 02-基本了解和学习资源
- Database learning notes II
- Niuniu looks at the cloud (greedy, hash, push formula) - the first session of Niuke winter vacation training camp
- 指南针炒股软件开户是合法的吗?安全吗
- Win11 open folder Caton solution summary
猜你喜欢

Go语言浅拷贝与深拷贝

Chapter VIII (classes and objects)

ASP. Net and Net framework and C #

PCB miscellaneous mail

记一次开发 pgadmin 时执行 Building the Web Assets 遇到的依赖安装问题

ReW_p

JMeter performance testing - Basic Concepts

Chapter 5 (array)

Two models of OSPF planning: double tower Raider and dog tooth crisscross

B站增量数据湖探索与实践
随机推荐
Apache InLong毕业成为顶级项目,具备百万亿级数据流处理能力!
QT之一个UI里边多界面切换
buuresevewp
Exploration and practice of incremental data Lake in station B
Apache inlong graduated as a top-level project with a million billion level data stream processing capability!
Ping An technology's practice of migrating from Oracle to ubisql
Power apps application practice | easily develop employee leave attendance management applet with power apps
Go language custom DNS resolver practice yyds dry inventory
[North Asia data recovery] a server data recovery method in which the partitions in the RAID5 array are formatted due to the misoperation of the NTFS file system
[UVM foundation] UVM_ Driver member variable req definition
解决 psycopg2.NotSupportedError: PQconninfo not available in libpq < 9.3
2022 ranking of bank financial products
Yyds dry inventory kubernetes easy service discovery and load balancing (11)
What is the five levels of cultivation of MES management system
Opencv mouse event + interface interaction drawing rectangle polygon selection ROI
Chapter 9 (using classes and objects)
[UVM practice] Chapter 2: a simple UVM verification platform (3) add various components to the verification platform
Leetcode topic [array] -11- containers with the most rainwater
ReW_p
Here is the command to display the disk space usage. Go ahead and pay attention to more wonderful things!