Skip to content

Commit

Permalink
Merge pull request #1286 from davidkuridza/main
Browse files Browse the repository at this point in the history
refactor: use slices from standard library
  • Loading branch information
tdakkota authored Aug 6, 2024
2 parents b7a31c4 + 12fe015 commit ade620b
Show file tree
Hide file tree
Showing 31 changed files with 31 additions and 38 deletions.
2 changes: 1 addition & 1 deletion conv/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"net"
"net/netip"
"net/url"
"slices"
"strconv"
"time"

"github.com/google/uuid"
"golang.org/x/exp/slices"
)

func ToInt(s string) (int, error) {
Expand Down
2 changes: 1 addition & 1 deletion dsl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package ogen

import (
"encoding/json"
"slices"
"strings"

"github.com/go-faster/jx"
"golang.org/x/exp/slices"

"github.com/ogen-go/ogen/jsonschema"
"github.com/ogen-go/ogen/openapi"
Expand Down
1 change: 0 additions & 1 deletion examples/hack.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ import (
_ "go.uber.org/zap"
_ "golang.org/x/exp/constraints"
_ "golang.org/x/exp/maps"
_ "golang.org/x/exp/slices"
_ "golang.org/x/tools/imports"
)
2 changes: 1 addition & 1 deletion gen/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package gen

import (
"fmt"
"slices"
"strings"

"github.com/go-faster/errors"
"github.com/ogen-go/ogen/gen/ir"
"go.uber.org/zap"
"golang.org/x/exp/slices"
)

type unimplementedError interface {
Expand Down
2 changes: 1 addition & 1 deletion gen/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package gen

import (
"fmt"
"slices"

"github.com/go-faster/errors"
"github.com/go-faster/yaml"
"golang.org/x/exp/slices"
)

// Feature is an ogen feature.
Expand Down
2 changes: 1 addition & 1 deletion gen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package gen
import (
"os"
"path/filepath"
"slices"
"strings"

"github.com/go-faster/errors"
"github.com/go-faster/yaml"
"go.uber.org/zap"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"

"github.com/ogen-go/ogen"
"github.com/ogen-go/ogen/gen/ir"
Expand Down
2 changes: 1 addition & 1 deletion gen/ir/examples.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package ir

import (
"slices"
"strings"

"github.com/go-faster/jx"
"golang.org/x/exp/slices"
)

func (t *Type) Examples() (r []string) {
Expand Down
3 changes: 1 addition & 2 deletions gen/ir/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ package ir

import (
"fmt"
"slices"
"strconv"
"strings"

"golang.org/x/exp/slices"

"github.com/ogen-go/ogen/internal/xmaps"
"github.com/ogen-go/ogen/jsonschema"
"github.com/ogen-go/ogen/openapi"
Expand Down
3 changes: 1 addition & 2 deletions gen/ir/json.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package ir

import (
"slices"
"strings"

"golang.org/x/exp/slices"

"github.com/ogen-go/ogen/internal/bitset"
"github.com/ogen-go/ogen/internal/naming"
"github.com/ogen-go/ogen/internal/xslices"
Expand Down
2 changes: 1 addition & 1 deletion gen/ir/params.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ir

import (
"golang.org/x/exp/slices"
"slices"

"github.com/ogen-go/ogen/openapi"
)
Expand Down
3 changes: 1 addition & 2 deletions gen/ir/recursion.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package ir
import (
"fmt"
"reflect"

"golang.org/x/exp/slices"
"slices"
)

func (t *Type) RecursiveTo(target *Type) bool {
Expand Down
3 changes: 1 addition & 2 deletions gen/ir/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ package ir

import (
"fmt"
"slices"
"strings"

"golang.org/x/exp/slices"
)

type ResponseInfo struct {
Expand Down
3 changes: 1 addition & 2 deletions gen/ir/template_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package ir

import (
"fmt"
"slices"
"strings"

"golang.org/x/exp/slices"

"github.com/ogen-go/ogen/internal/naming"
"github.com/ogen-go/ogen/jsonschema"
)
Expand Down
2 changes: 1 addition & 1 deletion gen/ir/type_features.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ir

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

func (t *Type) HasFeature(feature string) bool {
return slices.Contains(t.Features, feature)
Expand Down
3 changes: 1 addition & 2 deletions gen/ir/type_iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package ir

import (
"fmt"
"slices"
"strings"

"golang.org/x/exp/slices"

"github.com/ogen-go/ogen/internal/xmaps"
)

Expand Down
2 changes: 1 addition & 1 deletion gen/ir/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package ir
import (
"fmt"
"math/big"
"slices"

"github.com/go-faster/errors"
"github.com/go-faster/jx"
"golang.org/x/exp/slices"

"github.com/ogen-go/ogen/jsonschema"
"github.com/ogen-go/ogen/ogenregex"
Expand Down
2 changes: 1 addition & 1 deletion gen/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"path/filepath"
"regexp"
"runtime"
"slices"
"strings"

"github.com/go-faster/errors"
"github.com/go-faster/yaml"
"go.uber.org/zap"
"golang.org/x/exp/slices"

"github.com/ogen-go/ogen/gen/ir"
"github.com/ogen-go/ogen/internal/urlpath"
Expand Down
2 changes: 1 addition & 1 deletion gen/router.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package gen

import (
"slices"
"sort"
"strings"

"github.com/go-faster/errors"
"golang.org/x/exp/slices"

"github.com/ogen-go/ogen/gen/ir"
"github.com/ogen-go/ogen/openapi"
Expand Down
2 changes: 1 addition & 1 deletion gen/schema_gen_sum.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"fmt"
"path"
"reflect"
"slices"
"strings"

"github.com/go-faster/errors"
"github.com/go-faster/jx"
"golang.org/x/exp/slices"

"github.com/ogen-go/ogen/gen/ir"
"github.com/ogen-go/ogen/internal/xmaps"
Expand Down
2 changes: 1 addition & 1 deletion gen/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"regexp"
"runtime"
"runtime/pprof"
"slices"
"sync"
"text/template"

"github.com/go-faster/errors"
"golang.org/x/exp/slices"
"golang.org/x/sync/errgroup"
"golang.org/x/tools/imports"

Expand Down
3 changes: 1 addition & 2 deletions http/multipart_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import (
"io"
"mime/multipart"
"net/textproto"
"slices"
"strings"

"golang.org/x/exp/slices"
)

// MultipartFile is multipart form file.
Expand Down
3 changes: 2 additions & 1 deletion internal/xmaps/xmaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
package xmaps

import (
"slices"

"golang.org/x/exp/constraints"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
)

// SortedKeys returns a sorted slice of keys in the map.
Expand Down
2 changes: 1 addition & 1 deletion internal/xslices/xslices.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Package xslices provides some generic utilities missed from x/exp/slices.
package xslices

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

// Filter performs in-place filtering of a slice.
func Filter[S ~[]E, E any](s S, keep func(E) bool) S {
Expand Down
2 changes: 1 addition & 1 deletion jsonschema/infer.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package jsonschema

import (
"slices"
"strings"

"github.com/go-faster/errors"
"github.com/go-faster/jx"
"golang.org/x/exp/slices"
)

// Infer returns a JSON Schema that is inferred from the given JSON.
Expand Down
2 changes: 1 addition & 1 deletion jsonschema/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"fmt"
"go/token"
"math/big"
"slices"
"strings"

"github.com/go-faster/errors"
"golang.org/x/exp/slices"

ogenjson "github.com/ogen-go/ogen/json"
"github.com/ogen-go/ogen/jsonpointer"
Expand Down
2 changes: 1 addition & 1 deletion jsonschema/parser_enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package jsonschema

import (
"encoding/json"
"slices"

"github.com/go-faster/errors"
"github.com/go-faster/jx"
"golang.org/x/exp/slices"

"github.com/ogen-go/ogen/internal/xslices"
)
Expand Down
2 changes: 1 addition & 1 deletion location/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package location
import (
"fmt"
"io"
"slices"
"strings"

"github.com/go-faster/errors"
"github.com/go-faster/yaml"
"go.uber.org/multierr"
"golang.org/x/exp/slices"

"github.com/ogen-go/ogen/internal/xmaps"
)
Expand Down
2 changes: 1 addition & 1 deletion openapi/parser/parse_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package parser
import (
"fmt"
"go/token"
"slices"

"github.com/go-faster/errors"
"golang.org/x/exp/slices"

"github.com/ogen-go/ogen"
"github.com/ogen-go/ogen/jsonpointer"
Expand Down
2 changes: 1 addition & 1 deletion openapi/parser/resolve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"encoding/json"
"fmt"
"net/url"
"slices"
"strings"
"testing"

"github.com/go-faster/yaml"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"

"github.com/ogen-go/ogen"
"github.com/ogen-go/ogen/jsonschema"
Expand Down
2 changes: 1 addition & 1 deletion tools/mkformattest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"encoding/json"
"flag"
"os"
"slices"
"strings"

"github.com/go-faster/errors"
"golang.org/x/exp/slices"

"github.com/ogen-go/ogen"
"github.com/ogen-go/ogen/gen"
Expand Down
2 changes: 1 addition & 1 deletion tools/sgcollector/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
"net/http"
"net/url"
"regexp"
"slices"
"strings"
"time"

"github.com/go-faster/errors"
"github.com/go-faster/jx"
"github.com/go-faster/yaml"
"golang.org/x/exp/slices"

"github.com/ogen-go/ogen"
"github.com/ogen-go/ogen/gen"
Expand Down

0 comments on commit ade620b

Please sign in to comment.