Ok I will have a rethink. 

Is there a way I can control the expansion. I do not want to double the 
storage each time. I want to be able to control and limit the growth if 
necessary.

Thanks for the assistance. I will re-read the article.

On Tuesday, 15 October 2019 11:16:35 UTC+1, Stuart Davies wrote:
>
> Hi 
>
> I have a slice backed by an array. 
>
> My understanding is that I can extend the slice (append)  up to the 
> capacity of the array. 
>
> After that I do not understand the correct procedure. Append fails when 
> the backing array indexes are exceeded.
>
> So I have this temporary piece of code:
> if p.LineCount >= len(p.Offsets) {
>     newLen := p.LineCount + 50
>     sb := make([]int64, newLen)
>     for i := 0; i < p.LineCount; i++ {
>         sb[i] = p.Offsets[i]
>     }
>     p.Offsets = sb
> }
>
> I know there must be an array copy function that will do this more 
> efficiently but I failed to find it!
>
> Please help.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f4c93ab7-2024-4bd8-8768-2f3744836cc3%40googlegroups.com.

Reply via email to