New Upstream Release - golang-github-shogo82148-go-shuffle
Ready changes
Summary
Merged new upstream version: 0.0~git20220921.02e99dc (was: 0.0~git20180218.27e6095).
Resulting package
Built on 2022-11-08T23:37 (took 11m30s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-releases golang-github-shogo82148-go-shuffle-dev
Lintian Result
- golang-github-shogo82148-go-shuffle-dev_0.0~git20220921.02e99dc-1~jan+nur1_all.deb
- golang-github-shogo82148-go-shuffle_0.0~git20220921.02e99dc-1~jan+nur1.dsc
- golang-github-shogo82148-go-shuffle_0.0~git20220921.02e99dc-1~jan+nur1_amd64.buildinfo
- golang-github-shogo82148-go-shuffle_0.0~git20220921.02e99dc-1~jan+nur1_amd64.changes
Diff
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..9a19a1c
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,15 @@
+# Please see the documentation for all configuration options:
+# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
+
+version: 2
+updates:
+ - package-ecosystem: "gomod"
+ directory: "/"
+ schedule:
+ interval: "daily"
+
+ # Maintain dependencies for GitHub Actions
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "daily"
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
new file mode 100644
index 0000000..254d84e
--- /dev/null
+++ b/.github/workflows/codeql-analysis.yml
@@ -0,0 +1,70 @@
+# For most projects, this workflow file will not need changing; you simply need
+# to commit it to your repository.
+#
+# You may wish to alter this file to override the set of languages analyzed,
+# or to provide custom queries or build logic.
+#
+# ******** NOTE ********
+# We have attempted to detect the languages in your repository. Please check
+# the `language` matrix defined below to confirm you have the correct set of
+# supported CodeQL languages.
+#
+name: "CodeQL"
+
+on:
+ push:
+ branches: [ main ]
+ pull_request:
+ # The branches below must be a subset of the branches above
+ branches: [ main ]
+ schedule:
+ - cron: '27 4 * * 3'
+
+jobs:
+ analyze:
+ name: Analyze
+ runs-on: ubuntu-latest
+ permissions:
+ actions: read
+ contents: read
+ security-events: write
+
+ strategy:
+ fail-fast: false
+ matrix:
+ language: [ 'go' ]
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
+ # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ # Initializes the CodeQL tools for scanning.
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v2
+ with:
+ languages: ${{ matrix.language }}
+ # If you wish to specify custom queries, you can do so here or in a config file.
+ # By default, queries listed here will override any specified in a config file.
+ # Prefix the list here with "+" to use these queries and those in the config file.
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
+
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
+ # If this step fails, then you should remove it and run the build manually (see below)
+ - name: Autobuild
+ uses: github/codeql-action/autobuild@v2
+
+ # ℹ️ Command-line programs to run using the OS shell.
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
+
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
+ # and modify them (or add more) to build your code if your project
+ # uses a compiled language
+
+ #- run: |
+ # make bootstrap
+ # make release
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v2
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..da07e29
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,63 @@
+name: test
+on:
+ push:
+ pull_request:
+
+jobs:
+ test:
+ name: Test
+ runs-on: ${{ matrix.os }}
+ strategy:
+ fail-fast: false
+ matrix:
+ os:
+ - ubuntu-latest
+ go:
+ - "1.18"
+ - "1.17"
+ - "1.16"
+ - "1.15"
+ - "1.14"
+ - "1.13"
+ - "1.12"
+ - "1.11"
+ - "1.10"
+ - "1.9"
+ - "1.8"
+
+ steps:
+ - name: Set up Go ${{ matrix.go }}
+ uses: actions/setup-go@v3
+ with:
+ go-version: ${{ matrix.go }}
+ id: go
+ - run: |
+ go version
+ echo GOPATH="$GITHUB_WORKSPACE" >> "$GITHUB_ENV"
+ - name: Check out code into the Go module directory
+ uses: actions/checkout@v3
+ with:
+ path: src/github.com/shogo82148/go-shuffle
+
+ - name: Test
+ run: go test -v -coverprofile=coverage.txt .
+ env:
+ GO111MODULE: "on"
+ working-directory: src/github.com/shogo82148/go-shuffle
+
+ - name: Send coverage to coveralls.io
+ uses: shogo82148/actions-goveralls@v1
+ with:
+ path-to-profile: coverage.txt
+ parallel: true
+ working-directory: src/github.com/shogo82148/go-shuffle
+ flag-name: ${{ matrix.os }}-Go-${{ matrix.go }}
+
+ finish:
+ needs: test
+ runs-on: ubuntu-latest
+ steps:
+ - name: finish
+ uses: shogo82148/actions-goveralls@v1
+ with:
+ parallel-finished: true
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..e4eb3c6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+golang-github-shogo82148-go-shuffle (0.0~git20220921.02e99dc-1) UNRELEASED; urgency=low
+
+ * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk> Tue, 08 Nov 2022 23:26:21 -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