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
7package main
8
9func 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
19func 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