duanmei2805
2018-02-03 23:50在GO中从一个结构复制到另一个结构
I have two structs:
type struct1 struct{
arr [num1]byte
}
type struct2 struct{
b1 [n1]uint64
b2 [n2]uint64
b3 [n3]uint64
}
Now, I have two pointers to these structs:
p1 := new(struct1);
p2 := new(struct2);
and after some computations, I want to copy p2 to a specified part of p1. Something like:
copy(p1.arr[k:], p2);
Where k is a positive integer. It can be easily done in C using memcpy
, but I could not find an easy way to do it in GO without using any external libraries. Does anyone have any suggestions? I'll really appreciate it.
- 点赞
- 回答
- 收藏
- 复制链接分享
2条回答
为你推荐
- 取消引用结构指针是否会复制结构?
- pointers
- 1个回答
- 在不同类型的结构之间复制公共字段
- it技术
- 互联网问答
- IT行业问题
- 计算机技术
- 编程语言问答
- 1个回答
- 在Go中深度复制图形结构
- data-structures
- 1个回答
- 复制结构
- it技术
- 互联网问答
- IT行业问题
- 计算机技术
- 编程语言问答
- 1个回答
- 在Golang中深度复制数据结构
- struct
- 2个回答
换一换