Selection sort algorithm
On Stack Overflow duplicate questions are closed.

For your question, a search of Code Review Stack Exchange for "[go] selection sort" finds, amongst others,

Selection sort algorithm with increasing/decreasing sort options

which has several detailed answers that address your question. For example, the code for my answer, simplified for ascending order only, is

// selectionSort sorts the array a into ascending order.
// The selection sort algorithm is an in-place comparison sort
// with O(n*n) time complexity.
func selectionSort(a []int) {
    for i, x := range a[:len(a)-1] {
        k := i
        for j, y := range a[i+1 : len(a)] {
            if x &gt; y {
                // out of order
                k = i + 1 + j
                x = y
            }
        }
        a[k], a[i] = a[i], x
    }
}


My code is idomatic Go and it's more than twice as fast as your code when running a Go benchmark which sorts 1024 random integers.

BenchmarkDemas           300       4894852 ns/op
BenchmarkPeterSO        1000       2339806 ns/op