mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
all: gofmt -w -r 'interface{} -> any' (#2874)
This commit is contained in:
@@ -21,7 +21,7 @@ type config struct {
|
||||
// debug enable a debug logging.
|
||||
debug bool
|
||||
// log used for logging on debug mode.
|
||||
log func(...interface{})
|
||||
log func(...any)
|
||||
// hooks to execute on mutations.
|
||||
hooks *hooks
|
||||
}
|
||||
@@ -49,7 +49,7 @@ func Debug() Option {
|
||||
}
|
||||
|
||||
// Log sets the logging function for debug mode.
|
||||
func Log(fn func(...interface{})) Option {
|
||||
func Log(fn func(...any)) Option {
|
||||
return func(c *config) {
|
||||
c.log = fn
|
||||
}
|
||||
|
||||
@@ -267,11 +267,11 @@ func IsConstraintError(err error) bool {
|
||||
type selector struct {
|
||||
label string
|
||||
flds *[]string
|
||||
scan func(context.Context, interface{}) error
|
||||
scan func(context.Context, any) error
|
||||
}
|
||||
|
||||
// ScanX is like Scan, but panics if an error occurs.
|
||||
func (s *selector) ScanX(ctx context.Context, v interface{}) {
|
||||
func (s *selector) ScanX(ctx context.Context, v any) {
|
||||
if err := s.scan(ctx, v); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ type (
|
||||
// testing.T and testing.B and used by enttest.
|
||||
TestingT interface {
|
||||
FailNow()
|
||||
Error(...interface{})
|
||||
Error(...any)
|
||||
}
|
||||
|
||||
// Option configures client creation.
|
||||
|
||||
@@ -65,8 +65,8 @@ func (e NodeEdges) NextOrErr() (*Node, error) {
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Node) scanValues(columns []string) ([]interface{}, error) {
|
||||
values := make([]interface{}, len(columns))
|
||||
func (*Node) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case node.FieldID, node.FieldValue:
|
||||
@@ -82,7 +82,7 @@ func (*Node) scanValues(columns []string) ([]interface{}, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Node fields.
|
||||
func (n *Node) assignValues(columns []string, values []interface{}) error {
|
||||
func (n *Node) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ func IDNEQ(id int) predicate.Node {
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.Node {
|
||||
return predicate.Node(func(s *sql.Selector) {
|
||||
v := make([]interface{}, len(ids))
|
||||
v := make([]any, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
@@ -47,7 +47,7 @@ func IDIn(ids ...int) predicate.Node {
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.Node {
|
||||
return predicate.Node(func(s *sql.Selector) {
|
||||
v := make([]interface{}, len(ids))
|
||||
v := make([]any, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
@@ -106,7 +106,7 @@ func ValueNEQ(v int) predicate.Node {
|
||||
|
||||
// ValueIn applies the In predicate on the "value" field.
|
||||
func ValueIn(vs ...int) predicate.Node {
|
||||
v := make([]interface{}, len(vs))
|
||||
v := make([]any, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
@@ -117,7 +117,7 @@ func ValueIn(vs ...int) predicate.Node {
|
||||
|
||||
// ValueNotIn applies the NotIn predicate on the "value" field.
|
||||
func ValueNotIn(vs ...int) predicate.Node {
|
||||
v := make([]interface{}, len(vs))
|
||||
v := make([]any, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
|
||||
@@ -403,10 +403,10 @@ func (nq *NodeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Node, e
|
||||
if withFKs {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, node.ForeignKeys...)
|
||||
}
|
||||
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*Node).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []interface{}) error {
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Node{config: nq.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
@@ -609,7 +609,7 @@ func (ngb *NodeGroupBy) Aggregate(fns ...AggregateFunc) *NodeGroupBy {
|
||||
}
|
||||
|
||||
// Scan applies the group-by query and scans the result into the given value.
|
||||
func (ngb *NodeGroupBy) Scan(ctx context.Context, v interface{}) error {
|
||||
func (ngb *NodeGroupBy) Scan(ctx context.Context, v any) error {
|
||||
query, err := ngb.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -618,7 +618,7 @@ func (ngb *NodeGroupBy) Scan(ctx context.Context, v interface{}) error {
|
||||
return ngb.sqlScan(ctx, v)
|
||||
}
|
||||
|
||||
func (ngb *NodeGroupBy) sqlScan(ctx context.Context, v interface{}) error {
|
||||
func (ngb *NodeGroupBy) sqlScan(ctx context.Context, v any) error {
|
||||
for _, f := range ngb.fields {
|
||||
if !node.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
|
||||
@@ -665,7 +665,7 @@ type NodeSelect struct {
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ns *NodeSelect) Scan(ctx context.Context, v interface{}) error {
|
||||
func (ns *NodeSelect) Scan(ctx context.Context, v any) error {
|
||||
if err := ns.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -673,7 +673,7 @@ func (ns *NodeSelect) Scan(ctx context.Context, v interface{}) error {
|
||||
return ns.sqlScan(ctx, v)
|
||||
}
|
||||
|
||||
func (ns *NodeSelect) sqlScan(ctx context.Context, v interface{}) error {
|
||||
func (ns *NodeSelect) sqlScan(ctx context.Context, v any) error {
|
||||
rows := &sql.Rows{}
|
||||
query, args := ns.sql.Query()
|
||||
if err := ns.driver.Query(ctx, query, args, rows); err != nil {
|
||||
|
||||
@@ -202,12 +202,12 @@ func (*txDriver) Commit() error { return nil }
|
||||
func (*txDriver) Rollback() error { return nil }
|
||||
|
||||
// Exec calls tx.Exec.
|
||||
func (tx *txDriver) Exec(ctx context.Context, query string, args, v interface{}) error {
|
||||
func (tx *txDriver) Exec(ctx context.Context, query string, args, v any) error {
|
||||
return tx.tx.Exec(ctx, query, args, v)
|
||||
}
|
||||
|
||||
// Query calls tx.Query.
|
||||
func (tx *txDriver) Query(ctx context.Context, query string, args, v interface{}) error {
|
||||
func (tx *txDriver) Query(ctx context.Context, query string, args, v any) error {
|
||||
return tx.tx.Query(ctx, query, args, v)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user