Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3: Track changes in Go stdlib #8

Merged
merged 4 commits into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.21

- name: Unit tests
run: go test -v -coverprofile=cover.out ./...
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: '1.18'
go-version: '1.21'
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down
7 changes: 2 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
module github.com/bobg/go-generics/v2
module github.com/bobg/go-generics/v3

go 1.18
go 1.21

require (
github.com/mattn/go-sqlite3 v1.14.12
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
)

retract v2.0.0
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
github.com/mattn/go-sqlite3 v1.14.12 h1:TJ1bhYJPV44phC+IMu1u2K/i5RriLTPe+yc68XDJ1Z0=
github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb h1:PaBZQdo+iSDyHT053FjUCgZQ/9uqVwPOcl7KSWhKn6w=
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
2 changes: 1 addition & 1 deletion iter/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package iter_test
import (
"fmt"

"github.com/bobg/go-generics/v2/iter"
"github.com/bobg/go-generics/v3/iter"
)

func ExampleAccum() {
Expand Down
2 changes: 1 addition & 1 deletion iter/n.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package iter

import "github.com/bobg/go-generics/v2/internal"
import "github.com/bobg/go-generics/v3/internal"

// FirstN produces an iterator containing the first n elements of the input
// (or all of the input, if there are fewer than n elements).
Expand Down
21 changes: 2 additions & 19 deletions maps/dropin.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
package maps

import "golang.org/x/exp/maps"
import "maps"

// This file contains entrypoints for each of the functions in in golang.org/x/exp/maps.

// Keys returns the keys of the map m.
// The keys will be in an indeterminate order.
func Keys[M ~map[K]V, K comparable, V any](m M) []K {
return maps.Keys(m)
}

// Values returns the values of the map m.
// The values will be in an indeterminate order.
func Values[M ~map[K]V, K comparable, V any](m M) []V {
return maps.Values(m)
}
// This file contains entrypoints for each of the functions in the standard Go maps package.

// Equal reports whether two maps contain the same key/value pairs.
// Values are compared using ==.
Expand All @@ -28,11 +16,6 @@ func EqualFunc[M1 ~map[K]V1, M2 ~map[K]V2, K comparable, V1, V2 any](m1 M1, m2 M
return maps.EqualFunc(m1, m2, eq)
}

// Clear removes all entries from m, leaving it empty.
func Clear[M ~map[K]V, K comparable, V any](m M) {
maps.Clear(m)
}

// Clone returns a copy of m. This is a shallow clone:
// the new keys and values are set using ordinary assignment.
func Clone[M ~map[K]V, K comparable, V any](m M) M {
Expand Down
2 changes: 1 addition & 1 deletion maps/dropin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strconv"
"testing"

"github.com/bobg/go-generics/v2/slices"
"github.com/bobg/go-generics/v3/slices"
)

var m1 = map[int]int{1: 2, 2: 4, 4: 8, 8: 16}
Expand Down
29 changes: 28 additions & 1 deletion maps/maps.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// in Go 1.21 (https://go.dev/doc/go1.21#maps).
package maps

import "github.com/bobg/go-generics/v2/iter"
import "github.com/bobg/go-generics/v3/iter"

// Each calls a function on each key-value pair in the given map.
func Each[M ~map[K]V, K comparable, V any](m M, f func(K, V)) {
Expand Down Expand Up @@ -63,3 +63,30 @@ func InvertMulti[M ~map[K]V, K, V comparable](m M) map[V][]K {
}
return result
}

// Keys returns the keys of the map m.
// The keys will be in an indeterminate order.
func Keys[M ~map[K]V, K comparable, V any](m M) []K {
result := make([]K, 0, len(m))
for k := range m {
result = append(result, k)
}
return result
}

// Values returns the values of the map m.
// The values will be in an indeterminate order.
func Values[M ~map[K]V, K comparable, V any](m M) []V {
result := make([]V, 0, len(m))
for _, v := range m {
result = append(result, v)
}
return result
}

// Clear removes all entries from m, leaving it empty.
func Clear[M ~map[K]V, K comparable, V any](m M) {
for k := range m {
delete(m, k)
}
}
2 changes: 1 addition & 1 deletion maps/maps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"reflect"
"testing"

"github.com/bobg/go-generics/v2/iter"
"github.com/bobg/go-generics/v3/iter"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion parallel/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"sync"

"github.com/bobg/go-generics/v2/parallel"
"github.com/bobg/go-generics/v3/parallel"
)

func ExampleConsumers() {
Expand Down
2 changes: 1 addition & 1 deletion parallel/parallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"golang.org/x/sync/errgroup"

"github.com/bobg/go-generics/v2/iter"
"github.com/bobg/go-generics/v3/iter"
)

// Error is an error type for wrapping errors returned from worker goroutines.
Expand Down
2 changes: 1 addition & 1 deletion parallel/parallel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sync"
"testing"

"github.com/bobg/go-generics/v2/set"
"github.com/bobg/go-generics/v3/set"
)

func TestValues(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion set/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package set_test
import (
"fmt"

"github.com/bobg/go-generics/v2/set"
"github.com/bobg/go-generics/v3/set"
)

func ExampleDiff() {
Expand Down
4 changes: 2 additions & 2 deletions set/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
package set

import (
"github.com/bobg/go-generics/v2/iter"
"github.com/bobg/go-generics/v2/maps"
"github.com/bobg/go-generics/v3/iter"
"github.com/bobg/go-generics/v3/maps"
)

// Of is a set of elements of type T.
Expand Down
2 changes: 1 addition & 1 deletion slices/combinatorics.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package slices

import (
"github.com/bobg/go-generics/v2/iter"
"github.com/bobg/go-generics/v3/iter"
)

// Permutations produces an iterator over all permutations of s.
Expand Down
2 changes: 1 addition & 1 deletion slices/combinatorics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"reflect"
"testing"

"github.com/bobg/go-generics/v2/iter"
"github.com/bobg/go-generics/v3/iter"
)

func TestPermutations(t *testing.T) {
Expand Down
Loading
Loading