Go

Go

Made by DeepSource

Use copy() for sliding elements SCC-S1018

Anti-pattern
Major
Autofix

copy() permits using the same source and destination slice, even with overlapping ranges. This makes it ideal for sliding elements in a slice.

Bad practice

for i := 0; i < n; i++ {
    x[i] = x[offset+i]
}

Recommended

copy(x[:n], x[offset:])