Your method of generating the random numbers is fine, however xs
is empty, and Go doesn't automatically extend slices. You could use append, however since you know the size in advance, it's most efficient to replace
var xs []float64
with
xs := make([]float64, 10)
which will give it the right size initially.