简体   繁体   English

如何将一小片复制到大片的末尾

[英]How to copy a small slice to the end of a bigger slice

I'm looking for the equivalent of Java System.arraycopy() 我在寻找Java System.arraycopy()的等效项

Let's say I have 2 slices 假设我有2片

small := make([]byte, 4)
big := make([]byte, 10)

I'd like to copy the content of small to big at position 6 (the bytes of small being the last bytes of big 我想的内容复制smallbig在第6位(的字节数small为的最后一个字节的big

The only way I found is to write a loop. 我发现的唯一方法是编写一个循环。

使用内置的复制功能:

copy(big[6:], small) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM