New Upstream Snapshot - golang-github-shogo82148-go-shuffle
Ready changes
Summary
Merged new upstream version: 1.0.1+git20220921.1.02e99dc (was: 0.0~git20180218.27e6095).
Resulting package
Built on 2022-11-03T09:30 (took 6m46s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-snapshots golang-github-shogo82148-go-shuffle-dev
Lintian Result
- golang-github-shogo82148-go-shuffle-dev_1.0.1+git20220921.1.02e99dc-1~jan+nus1_all.deb
- golang-github-shogo82148-go-shuffle_1.0.1+git20220921.1.02e99dc-1~jan+nus1.dsc
- golang-github-shogo82148-go-shuffle_1.0.1+git20220921.1.02e99dc-1~jan+nus1_amd64.buildinfo
- golang-github-shogo82148-go-shuffle_1.0.1+git20220921.1.02e99dc-1~jan+nus1_amd64.changes
Diff
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index d1c302a..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-language: go
-
-go:
- - '1.3.x'
- - '1.4.x'
- - '1.5.x'
- - '1.6.x'
- - '1.7.x'
- - '1.8.x'
- - '1.9.x'
- - '1.10.x'
- - 'tip'
diff --git a/README.md b/README.md
index fa22dba..0216e58 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,11 @@
-go-shuffle
-=====
+# go-shuffle
-[![Build Status](https://travis-ci.org/shogo82148/go-shuffle.svg?branch=master)](https://travis-ci.org/shogo82148/go-shuffle)
+[![test](https://github.com/shogo82148/go-shuffle/actions/workflows/test.yml/badge.svg)](https://github.com/shogo82148/go-shuffle/actions/workflows/test.yml)
+[![Go Reference](https://pkg.go.dev/badge/github.com/shogo82148/go-shuffle.svg)](https://pkg.go.dev/github.com/shogo82148/go-shuffle)
Package shuffle provides primitives for shuffling slices and user-defined collections.
-``` go
+```go
import "github.com/shogo82148/go-shuffle"
// Shuffle slice of int.
@@ -31,7 +31,7 @@ shuffle.Slice(strings)
shuffle.Slice(float64s)
```
-See [godoc](https://godoc.org/github.com/shogo82148/go-shuffle) for more information.
+See [godoc](https://pkg.go.dev/github.com/shogo82148/go-shuffle) for more information.
# LICENSE
diff --git a/debian/changelog b/debian/changelog
index 23d5387..c1a33f0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+golang-github-shogo82148-go-shuffle (1.0.1+git20220921.1.02e99dc-1) UNRELEASED; urgency=low
+
+ * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk> Thu, 03 Nov 2022 09:26:01 -0000
+
golang-github-shogo82148-go-shuffle (0.0~git20180218.27e6095-1) unstable; urgency=medium
[ Alexandre Viau ]
diff --git a/shuffle_go17_test.go b/example_test.go
similarity index 98%
rename from shuffle_go17_test.go
rename to example_test.go
index bcb061a..8d8d25e 100644
--- a/shuffle_go17_test.go
+++ b/example_test.go
@@ -1,5 +1,3 @@
-//+build go1.7
-
package shuffle_test
import (
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..8b96603
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,3 @@
+module github.com/shogo82148/go-shuffle
+
+go 1.16
diff --git a/shuffle.go b/shuffle.go
index 96ebe46..bd4fdde 100644
--- a/shuffle.go
+++ b/shuffle.go
@@ -1,15 +1,20 @@
-//+build go1.10
+//go:build go1.10
+// +build go1.10
// Package shuffle provides primitives for shuffling slices and user-defined
// collections.
+//
+// As of Go 1.10, the same functionality is now provided by package math/rand,
+// and those implementations should be preferred in new code.
package shuffle
import (
"math/rand"
- "sort"
)
// Shuffle shuffles Data.
+//
+// As of Go 1.10, it just calls rand.Shuffle(data.Len(), data.Swap).
func Shuffle(data Interface) {
rand.Shuffle(data.Len(), data.Swap)
}
@@ -22,15 +27,29 @@ type Shuffler rand.Rand
func New(src rand.Source) *Shuffler { return (*Shuffler)(rand.New(src)) }
// Shuffle shuffles Data.
+//
+// As of Go 1.10, it just calls (*rand.Rand).Shuffle(data.Len(), data.Swap).
func (s *Shuffler) Shuffle(data Interface) {
- rand.Shuffle(data.Len(), data.Swap)
+ (*rand.Rand)(s).Shuffle(data.Len(), data.Swap)
}
// Ints shuffles a slice of ints.
-func (s *Shuffler) Ints(a []int) { s.Shuffle(sort.IntSlice(a)) }
+//
+// As of Go 1.10, it just calls (*rand.Rand).Shuffle(len(a), func(i, j int) { a[i], a[j] = a[j], a[i]}).
+func (s *Shuffler) Ints(a []int) {
+ (*rand.Rand)(s).Shuffle(len(a), func(i, j int) { a[i], a[j] = a[j], a[i] })
+}
// Float64s shuffles a slice of float64s.
-func (s *Shuffler) Float64s(a []float64) { s.Shuffle(sort.Float64Slice(a)) }
+//
+// As of Go 1.10, it just calls (*rand.Rand).Shuffle(len(a), func(i, j int) { a[i], a[j] = a[j], a[i]}).
+func (s *Shuffler) Float64s(a []float64) {
+ (*rand.Rand)(s).Shuffle(len(a), func(i, j int) { a[i], a[j] = a[j], a[i] })
+}
// Strings shuffles a slice of strings.
-func (s *Shuffler) Strings(a []string) { s.Shuffle(sort.StringSlice(a)) }
+//
+// As of Go 1.10, it just calls (*rand.Rand).Shuffle(len(a), func(i, j int) { a[i], a[j] = a[j], a[i]}).
+func (s *Shuffler) Strings(a []string) {
+ (*rand.Rand)(s).Shuffle(len(a), func(i, j int) { a[i], a[j] = a[j], a[i] })
+}
diff --git a/shuffle_go1.9.go b/shuffle_go1.9.go
index 9963967..8e71c79 100644
--- a/shuffle_go1.9.go
+++ b/shuffle_go1.9.go
@@ -1,4 +1,5 @@
-//+build !go1.10
+//go:build !go1.10
+// +build !go1.10
// Package shuffle provides primitives for shuffling slices and user-defined
// collections.
@@ -6,6 +7,7 @@ package shuffle
import (
"math/rand"
+ "reflect"
"sort"
)
@@ -42,3 +44,25 @@ func (s *Shuffler) Float64s(a []float64) { s.Shuffle(sort.Float64Slice(a)) }
// Strings shuffles a slice of strings.
func (s *Shuffler) Strings(a []string) { s.Shuffle(sort.StringSlice(a)) }
+
+// Slice shuffles the slice.
+func Slice(slice interface{}) {
+ rv := reflect.ValueOf(slice)
+ swap := reflect.Swapper(slice)
+ n := rv.Len()
+ for i := n - 1; i >= 0; i-- {
+ j := rand.Intn(i + 1)
+ swap(i, j)
+ }
+}
+
+// Slice shuffles the slice.
+func (s *Shuffler) Slice(slice Interface) {
+ rv := reflect.ValueOf(slice)
+ swap := reflect.Swapper(slice)
+ n := rv.Len()
+ for i := n - 1; i >= 0; i-- {
+ j := (*rand.Rand)(s).Intn(i + 1)
+ swap(i, j)
+ }
+}
diff --git a/shuffle_slice.go b/shuffle_slice.go
index 4ac1203..de4077c 100644
--- a/shuffle_slice.go
+++ b/shuffle_slice.go
@@ -1,4 +1,5 @@
-//+build go1.10
+//go:build go1.10
+// +build go1.10
package shuffle
@@ -15,7 +16,7 @@ func Slice(slice interface{}) {
}
// Slice shuffles the slice.
-func (s *Shuffler) Slice(slice Interface) {
+func (s *Shuffler) Slice(slice interface{}) {
rv := reflect.ValueOf(slice)
swap := reflect.Swapper(slice)
(*rand.Rand)(s).Shuffle(rv.Len(), swap)
diff --git a/shuffle_slice_g1.9.go b/shuffle_slice_g1.9.go
deleted file mode 100644
index 309917b..0000000
--- a/shuffle_slice_g1.9.go
+++ /dev/null
@@ -1,30 +0,0 @@
-//+build go1.8,!go1.10
-
-package shuffle
-
-import (
- "math/rand"
- "reflect"
-)
-
-// Slice shuffles the slice.
-func Slice(slice interface{}) {
- rv := reflect.ValueOf(slice)
- swap := reflect.Swapper(slice)
- n := rv.Len()
- for i := n - 1; i >= 0; i-- {
- j := rand.Intn(i + 1)
- swap(i, j)
- }
-}
-
-// Slice shuffles the slice.
-func (s *Shuffler) Slice(slice Interface) {
- rv := reflect.ValueOf(slice)
- swap := reflect.Swapper(slice)
- n := rv.Len()
- for i := n - 1; i >= 0; i-- {
- j := (*rand.Rand)(s).Intn(i + 1)
- swap(i, j)
- }
-}
diff --git a/shuffle_slice_test.go b/shuffle_slice_test.go
index c9e011d..6eaf3b7 100644
--- a/shuffle_slice_test.go
+++ b/shuffle_slice_test.go
@@ -1,5 +1,3 @@
-//+build go1.8
-
package shuffle
import (
@@ -57,6 +55,7 @@ func BenchmarkStructs(b *testing.B) {
b.Run(fmt.Sprintf("shuffle %d", n), func(b *testing.B) {
a := make([]Struct, n)
+ _ = a[0].data
for i := 0; i < b.N; i++ {
Slice(a)
}
Debdiff
[The following lists of changes regard files as different if they have different names, permissions or owners.]
Files in second set of .debs but not in first
-rw-r--r-- root/root /usr/share/gocode/src/github.com/shogo82148/go-shuffle/example_test.go -rw-r--r-- root/root /usr/share/gocode/src/github.com/shogo82148/go-shuffle/go.mod
Files in first set of .debs but not in second
-rw-r--r-- root/root /usr/share/gocode/src/github.com/shogo82148/go-shuffle/shuffle_go17_test.go -rw-r--r-- root/root /usr/share/gocode/src/github.com/shogo82148/go-shuffle/shuffle_slice_g1.9.go
No differences were encountered in the control files