In this short tutorial, we’re going to learn how to swap elements in a **Go slice**.

## Create a Slice of Integers

The first we need to do is create a slice of **integers:**

```
// Create a Slice of Integers with the same length and capacity.
var numbers = make([]int, 5)
// Assign the numbers 0 - 4 to the slice.
for i := range numbers {
numbers[i] = i
}
```

The slice will look like** this:**

## Swap Elements in the Slice

Here we will swap the elements at **indexes 0 and 4:**

```
// Swap the elements at indexes of 0 and 4.
numbers[0], numbers[4] = numbers[4], numbers[0]
```

After this code runs the slice will look like this:

## Full Program

Below is the** full source:**

```
package main
func main() {
// Create a slice of integers with the same length and capacity.
var numbers = make([]int, 5)
// Add the numbers 0 - 4 to the slice.
for i := range numbers {
numbers[i] = i
}
// Swap the elements at indexes of 0 and 4.
numbers[0], numbers[4] = numbers[4], numbers[0]
}
```