diff --git a/internal/experiment/openvpn/targets.go b/internal/experiment/openvpn/targets.go index 99fdb7dd5..f109d47f3 100644 --- a/internal/experiment/openvpn/targets.go +++ b/internal/experiment/openvpn/targets.go @@ -31,21 +31,10 @@ func sampleN(a []string, n int) []string { if n > len(a) { n = len(a) } - - sampled := make([]string, 0) - - // Use a map to track indices we've already selected to avoid duplicates - picked := make(map[int]struct{}) - - for len(sampled) < n { - idx := rand.Intn(len(a)) // Random index - if _, exists := picked[idx]; !exists { - sampled = append(sampled, a[idx]) - picked[idx] = struct{}{} // Mark index as used - } - } - - return sampled + rand.Shuffle(len(a), func(i, j int) { + a[i], a[j] = a[j], a[i] + }) + return a[:n] } // resolveOONIAddresses returns a max of maxDefaultOONIAddresses after