Skip to content

Commit

Permalink
Remove golang.org/x/exp dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
utgwkk committed Oct 29, 2024
1 parent 7086387 commit 789b83f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cmd/bulkmockgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (
"os/exec"
"os/signal"

"slices"

"github.com/utgwkk/bulkmockgen/generator"
"golang.org/x/exp/slices"
)

var (
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ require (
github.com/stoewer/go-strcase v1.3.0
github.com/stretchr/testify v1.9.0
go.uber.org/mock v0.5.0
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df
golang.org/x/tools v0.26.0
)

Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU=
go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM=
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME=
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
Expand Down
16 changes: 16 additions & 0 deletions migrator/internal/map_keys.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package internal

import (
"cmp"
"slices"
)

func MapKeys[M ~map[K]V, K cmp.Ordered, V any](m M) []K {
keys := make([]K, 0, len(m))
for key := range m {
keys = append(keys, key)
}

slices.Sort(keys)
return keys
}
5 changes: 2 additions & 3 deletions migrator/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

"github.com/gertd/go-pluralize"
"github.com/stoewer/go-strcase"
"golang.org/x/exp/maps"
"github.com/utgwkk/bulkmockgen/migrator/internal"
"golang.org/x/tools/imports"
)

Expand Down Expand Up @@ -103,8 +103,7 @@ func (m *Migrator) Migrate() error {
}

// output code with determinate order
keys := maps.Keys(interfacesByPackageName)
sort.Strings(keys)
keys := internal.MapKeys(interfacesByPackageName)

w.Write([]byte(fmt.Sprintf("package %s\n\n", sourcePkg)))
for _, pkgName := range keys {
Expand Down

0 comments on commit 789b83f

Please sign in to comment.