Re: [go-nuts] What's going on while using "append" in memory?

2021-08-08 Thread Miraddo
Thanks, Brain. It is absolutely fantastic. I saw this SliceTricks two days ago. Nice to mention it. On Sunday, August 8, 2021 at 8:36:27 PM UTC+4:30 Brian Candler wrote: > On Friday, 6 August 2021 at 18:00:35 UTC+1 Konstantin Khomoutov wrote: > >> Have you read and understood [1] and [2]? >> >

Re: [go-nuts] What's going on while using "append" in memory?

2021-08-08 Thread Miraddo
Henry Thanks for your time, You're right. Sounds reasonable. But you know, the first time I saw this thing, I was like, when I pass the new slice to my existing slice, does it not replace the item in the same address in memory that my slice has before? Because when I pass new data to my variabl

Re: [go-nuts] What's going on while using "append" in memory?

2021-08-08 Thread Miraddo
Thank you, Konstantin. I really appreciate your response, I didn't read those links before you sent them to me, but I read them yesterday, now everything is so clear to me, and I know what is going on with "slice," "append," and "copy" in memory. I was so confused, but now I know what's going on

Re: [go-nuts] What's going on while using "append" in memory?

2021-08-08 Thread Brian Candler
On Friday, 6 August 2021 at 18:00:35 UTC+1 Konstantin Khomoutov wrote: > Have you read and understood [1] and [2]? > ... > 1. https://blog.golang.org/slices-intro > 2. https://blog.golang.org/slices > > Also possibly of interest (although it doesn't mention rotation): https://github.com/golang/

Re: [go-nuts] What's going on while using "append" in memory?

2021-08-08 Thread Henry
Append is for appending items at the end of a slice. If there is enough space, Go will simply append the items and return the slice. If there is not enough space, Go will create a new slice with double the capacity of the existing slice or at least enough space to hold the new items (whichever