Deepak Jois, Consider this case:
The Go Programming Language Specification https://golang.org/ref/spec Slice expressions https://golang.org/ref/spec#Slice_expressions Full slice expressions For an array, pointer to array, or slice a (but not a string), the primary expression a[low : high : max] constructs a slice of the same type, and with the same length and elements as the simple slice expression a[low : high]. Additionally, it controls the resulting slice's capacity by setting it to max - low. Only the first index may be omitted; it defaults to 0. Peter On Thursday, September 7, 2017 at 1:54:16 AM UTC-4, Deepak Jois wrote: > > Hi > > Pls look at this code: https://play.golang.org/p/QfQOo1iyp4 > > I am copying a slice over itself. How does it work internally? Does > the copy operation optimise for this, and not perform any copying in > this case? > > I have to deal with a situation where I get a slice reference back > from a function, and it is possible that it points to the same slice > that I am trying to copy it into. It would be nice if the copy > operation in that case is a no-op, but I don’t want to assume that is > the case. > > Deepak > -- 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. For more options, visit https://groups.google.com/d/optout.