Source file test/fixedbugs/issue36259.go
1 // compile 2 3 // Copyright 2019 The Go Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 package main 8 9 func rotate(s []int, m int) { 10 l := len(s) 11 m = m % l 12 buf := make([]int, m) 13 14 copy(buf, s) 15 copy(s, s[m:]) 16 copy(s[l-m:], buf) 17 } 18 19 func main() { 20 a0 := [...]int{1,2,3,4,5} 21 println(a0[0]) 22 23 rotate(a0[:], 1) 24 println(a0[0]) 25 26 rotate(a0[:], -3) 27 println(a0[0]) 28 } 29