Skip to content

Commit f2ac5c1

Browse files
committed
refactor: migrate golang.org/x/exp to stds
Signed-off-by: Morlay <[email protected]>
1 parent 84b7d5a commit f2ac5c1

File tree

9 files changed

+15
-19
lines changed

9 files changed

+15
-19
lines changed

go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ require (
1313
github.com/sirupsen/logrus v1.9.0
1414
github.com/stretchr/testify v1.8.4
1515
github.com/xeipuuv/gojsonschema v1.2.0
16-
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3
1716
golang.org/x/sync v0.3.0
1817
gopkg.in/yaml.v3 v3.0.1
1918
gotest.tools/v3 v3.4.0

go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
3535
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
3636
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
3737
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
38-
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 h1:hNQpMuAJe5CtcUqCXaWga3FHu+kQvCqcsoVaQgSV60o=
39-
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
4038
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
4139
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
4240
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=

graph/cycle.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ package graph
1818

1919
import (
2020
"fmt"
21+
"slices"
2122
"strings"
2223

2324
"github.com/compose-spec/compose-go/v2/types"
2425
"github.com/compose-spec/compose-go/v2/utils"
25-
"golang.org/x/exp/slices"
2626
)
2727

2828
// CheckCycle analyze project's depends_on relation and report an error on cycle detection

graph/traversal.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ package graph
1818

1919
import (
2020
"context"
21+
"slices"
2122
"sync"
2223

23-
"golang.org/x/exp/slices"
2424
"golang.org/x/sync/errgroup"
2525
)
2626

loader/loader.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"path/filepath"
2727
"reflect"
2828
"regexp"
29+
"slices"
2930
"strconv"
3031
"strings"
3132

@@ -42,7 +43,6 @@ import (
4243
"github.com/compose-spec/compose-go/v2/validation"
4344
"github.com/go-viper/mapstructure/v2"
4445
"github.com/sirupsen/logrus"
45-
"golang.org/x/exp/slices"
4646
"gopkg.in/yaml.v3"
4747
)
4848

override/merge.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ package override
1919
import (
2020
"cmp"
2121
"fmt"
22+
"slices"
2223
"strings"
2324

2425
"github.com/compose-spec/compose-go/v2/tree"
25-
"golang.org/x/exp/slices"
2626
)
2727

2828
// Merge applies overrides to a config model

types/project.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,17 @@ import (
2121
"context"
2222
"encoding/json"
2323
"fmt"
24+
"maps"
2425
"os"
2526
"path/filepath"
27+
"slices"
2628
"sort"
2729

2830
"github.com/compose-spec/compose-go/v2/dotenv"
2931
"github.com/compose-spec/compose-go/v2/errdefs"
3032
"github.com/compose-spec/compose-go/v2/utils"
3133
"github.com/distribution/reference"
3234
godigest "github.com/opencontainers/go-digest"
33-
"golang.org/x/exp/maps"
3435
"golang.org/x/sync/errgroup"
3536
"gopkg.in/yaml.v3"
3637
)
@@ -120,21 +121,21 @@ func (p *Project) ServicesWithBuild() []string {
120121
servicesBuild := p.Services.Filter(func(s ServiceConfig) bool {
121122
return s.Build != nil && s.Build.Context != ""
122123
})
123-
return maps.Keys(servicesBuild)
124+
return slices.AppendSeq(make([]string, 0), maps.Keys(servicesBuild))
124125
}
125126

126127
func (p *Project) ServicesWithExtends() []string {
127128
servicesExtends := p.Services.Filter(func(s ServiceConfig) bool {
128129
return s.Extends != nil && *s.Extends != (ExtendsConfig{})
129130
})
130-
return maps.Keys(servicesExtends)
131+
return slices.AppendSeq(make([]string, 0), maps.Keys(servicesExtends))
131132
}
132133

133134
func (p *Project) ServicesWithDependsOn() []string {
134135
servicesDependsOn := p.Services.Filter(func(s ServiceConfig) bool {
135136
return len(s.DependsOn) > 0
136137
})
137-
return maps.Keys(servicesDependsOn)
138+
return slices.AppendSeq(make([]string, 0), maps.Keys(servicesDependsOn))
138139
}
139140

140141
func (p *Project) ServicesWithCapabilities() ([]string, []string, []string) {

types/project_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import (
2020
_ "crypto/sha256"
2121
"errors"
2222
"fmt"
23+
"slices"
2324
"strings"
2425
"testing"
2526

2627
"github.com/compose-spec/compose-go/v2/utils"
2728
"github.com/distribution/reference"
2829
"github.com/opencontainers/go-digest"
29-
"golang.org/x/exp/slices"
3030
"gotest.tools/v3/assert"
3131
)
3232

utils/collectionutils.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@
1717
package utils
1818

1919
import (
20-
"golang.org/x/exp/constraints"
21-
"golang.org/x/exp/maps"
22-
"golang.org/x/exp/slices"
20+
"cmp"
21+
"maps"
22+
"slices"
2323
)
2424

25-
func MapKeys[T constraints.Ordered, U any](theMap map[T]U) []T {
26-
result := maps.Keys(theMap)
27-
slices.Sort(result)
28-
return result
25+
func MapKeys[T cmp.Ordered, U any](theMap map[T]U) []T {
26+
return slices.Sorted(maps.Keys(theMap))
2927
}
3028

3129
func MapsAppend[T comparable, U any](target map[T]U, source map[T]U) map[T]U {

0 commit comments

Comments
 (0)