diff --git a/README.md b/README.md index c1eccc1..1d1daa4 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ element to be selected are not equal, but rather defined by relative "weights" ```go import ( /* ...snip... */ - "github.com/mroth/weightedrand" + "github.com/mroth/weightedrand/v2" ) func main() { @@ -73,6 +73,11 @@ right choice! If you are only picking from the same distribution once, `randutil` will be faster. `weightedrand` optimizes for repeated calls at the expense of some initialization time and memory storage. +## Requirements + +weightedrand >= v2 requires go1.18 or greater. For support on earlier versions +of go, use weightedrand [v1](https://github.com/mroth/weightedrand/tree/v1). + ## Credits To better understand the algorithm used in this library (as well as the one used diff --git a/examples/compbench/bench_test.go b/examples/compbench/bench_test.go index 6a6f7e4..c8e417b 100644 --- a/examples/compbench/bench_test.go +++ b/examples/compbench/bench_test.go @@ -9,7 +9,7 @@ import ( "time" "github.com/jmcvetta/randutil" - "github.com/mroth/weightedrand" + "github.com/mroth/weightedrand/v2" ) const BMMinChoices = 10 @@ -98,9 +98,9 @@ func BenchmarkSingle(b *testing.B) { }) } -func mockChoices(tb testing.TB, n int) []weightedrand.Choice { +func mockChoices(tb testing.TB, n int) []weightedrand.Choice[rune, uint] { tb.Helper() - choices := make([]weightedrand.Choice, 0, n) + choices := make([]weightedrand.Choice[rune, uint], 0, n) for i := 0; i < n; i++ { s := '🥑' w := rand.Intn(10) @@ -110,7 +110,7 @@ func mockChoices(tb testing.TB, n int) []weightedrand.Choice { return choices } -func convertChoices(tb testing.TB, cs []weightedrand.Choice) []randutil.Choice { +func convertChoices(tb testing.TB, cs []weightedrand.Choice[rune, uint]) []randutil.Choice { tb.Helper() res := make([]randutil.Choice, len(cs)) for i, c := range cs { diff --git a/examples/compbench/go.mod b/examples/compbench/go.mod index 205ae69..bc67fc8 100644 --- a/examples/compbench/go.mod +++ b/examples/compbench/go.mod @@ -1,10 +1,10 @@ module github.com/mroth/weightedrand/examples/compbench -go 1.15 +go 1.18 require ( github.com/jmcvetta/randutil v0.0.0-20150817122601-2bb1b664bcff - github.com/mroth/weightedrand v0.0.0 + github.com/mroth/weightedrand/v2 v2.0.0 ) -replace github.com/mroth/weightedrand => ../.. +replace github.com/mroth/weightedrand/v2 => ../.. diff --git a/examples/frequency/main.go b/examples/frequency/main.go index 18ed4a4..08db4af 100644 --- a/examples/frequency/main.go +++ b/examples/frequency/main.go @@ -6,7 +6,7 @@ import ( "math/rand" "time" - "github.com/mroth/weightedrand" + "github.com/mroth/weightedrand/v2" ) func main() { diff --git a/go.mod b/go.mod index 68c1df7..1ed6cf1 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/mroth/weightedrand +module github.com/mroth/weightedrand/v2 go 1.18