all: gofmt -w -r 'interface{} -> any' (#2874)

This commit is contained in:
Ariel Mashraki
2022-08-19 18:23:04 +03:00
committed by GitHub
parent b6c185a660
commit 2c63d1d70e
619 changed files with 3449 additions and 3449 deletions

View File

@@ -7,58 +7,58 @@ package __
import "entgo.io/ent/dialect/gremlin/graph/dsl"
// As is the api for calling __.As().
func As(args ...interface{}) *dsl.Traversal { return New().As(args...) }
func As(args ...any) *dsl.Traversal { return New().As(args...) }
// Is is the api for calling __.Is().
func Is(args ...interface{}) *dsl.Traversal { return New().Is(args...) }
func Is(args ...any) *dsl.Traversal { return New().Is(args...) }
// Not is the api for calling __.Not().
func Not(args ...interface{}) *dsl.Traversal { return New().Not(args...) }
func Not(args ...any) *dsl.Traversal { return New().Not(args...) }
// Has is the api for calling __.Has().
func Has(args ...interface{}) *dsl.Traversal { return New().Has(args...) }
func Has(args ...any) *dsl.Traversal { return New().Has(args...) }
// HasNot is the api for calling __.HasNot().
func HasNot(args ...interface{}) *dsl.Traversal { return New().HasNot(args...) }
func HasNot(args ...any) *dsl.Traversal { return New().HasNot(args...) }
// Or is the api for calling __.Or().
func Or(args ...interface{}) *dsl.Traversal { return New().Or(args...) }
func Or(args ...any) *dsl.Traversal { return New().Or(args...) }
// And is the api for calling __.And().
func And(args ...interface{}) *dsl.Traversal { return New().And(args...) }
func And(args ...any) *dsl.Traversal { return New().And(args...) }
// In is the api for calling __.In().
func In(args ...interface{}) *dsl.Traversal { return New().In(args...) }
func In(args ...any) *dsl.Traversal { return New().In(args...) }
// Out is the api for calling __.Out().
func Out(args ...interface{}) *dsl.Traversal { return New().Out(args...) }
func Out(args ...any) *dsl.Traversal { return New().Out(args...) }
// OutE is the api for calling __.OutE().
func OutE(args ...interface{}) *dsl.Traversal { return New().OutE(args...) }
func OutE(args ...any) *dsl.Traversal { return New().OutE(args...) }
// InE is the api for calling __.InE().
func InE(args ...interface{}) *dsl.Traversal { return New().InE(args...) }
func InE(args ...any) *dsl.Traversal { return New().InE(args...) }
// InV is the api for calling __.InV().
func InV(args ...interface{}) *dsl.Traversal { return New().InV(args...) }
func InV(args ...any) *dsl.Traversal { return New().InV(args...) }
// V is the api for calling __.V().
func V(args ...interface{}) *dsl.Traversal { return New().V(args...) }
func V(args ...any) *dsl.Traversal { return New().V(args...) }
// OutV is the api for calling __.OutV().
func OutV(args ...interface{}) *dsl.Traversal { return New().OutV(args...) }
func OutV(args ...any) *dsl.Traversal { return New().OutV(args...) }
// Values is the api for calling __.Values().
func Values(args ...string) *dsl.Traversal { return New().Values(args...) }
// Union is the api for calling __.Union().
func Union(args ...interface{}) *dsl.Traversal { return New().Union(args...) }
func Union(args ...any) *dsl.Traversal { return New().Union(args...) }
// Constant is the api for calling __.Constant().
func Constant(args ...interface{}) *dsl.Traversal { return New().Constant(args...) }
func Constant(args ...any) *dsl.Traversal { return New().Constant(args...) }
// Properties is the api for calling __.Properties().
func Properties(args ...interface{}) *dsl.Traversal { return New().Properties(args...) }
func Properties(args ...any) *dsl.Traversal { return New().Properties(args...) }
// OtherV is the api for calling __.OtherV().
func OtherV() *dsl.Traversal { return New().OtherV() }

View File

@@ -18,7 +18,7 @@ import (
// Node represents a DSL step in the traversal.
type Node interface {
// Code returns the code representation of the element and its bindings (if any).
Code() (string, []interface{})
Code() (string, []any)
}
type (
@@ -26,46 +26,46 @@ type (
Token string
// List represents a list of elements.
List struct {
Elements []interface{}
Elements []any
}
// Func represents a function call.
Func struct {
Name string
Args []interface{}
Args []any
}
// Block represents a block/group of nodes.
Block struct {
Nodes []interface{}
Nodes []any
}
// Var represents a variable assignment and usage.
Var struct {
Name string
Elem interface{}
Elem any
}
)
// Code stringified the token.
func (t Token) Code() (string, []interface{}) { return string(t), nil }
func (t Token) Code() (string, []any) { return string(t), nil }
// Code returns the code representation of a list.
func (l List) Code() (string, []interface{}) {
func (l List) Code() (string, []any) {
c, args := codeList(", ", l.Elements...)
return fmt.Sprintf("[%s]", c), args
}
// Code returns the code representation of a function call.
func (f Func) Code() (string, []interface{}) {
func (f Func) Code() (string, []any) {
c, args := codeList(", ", f.Args...)
return fmt.Sprintf("%s(%s)", f.Name, c), args
}
// Code returns the code representation of group/block of nodes.
func (b Block) Code() (string, []interface{}) {
func (b Block) Code() (string, []any) {
return codeList("; ", b.Nodes...)
}
// Code returns the code representation of variable declaration or its identifier.
func (v Var) Code() (string, []interface{}) {
func (v Var) Code() (string, []any) {
c, args := code(v.Elem)
if v.Name == "" {
return c, args
@@ -80,12 +80,12 @@ var (
)
// NewFunc returns a new function node.
func NewFunc(name string, args ...interface{}) *Func {
func NewFunc(name string, args ...any) *Func {
return &Func{Name: name, Args: args}
}
// NewList returns a new list node.
func NewList(args ...interface{}) *List {
func NewList(args ...any) *List {
return &List{Elements: args}
}
@@ -96,10 +96,10 @@ type Querier interface {
}
// Bindings are used to associate a variable with a value.
type Bindings map[string]interface{}
type Bindings map[string]any
// Add adds new value to the bindings map, formats it if needed, and returns its generated name.
func (b Bindings) Add(v interface{}) string {
func (b Bindings) Add(v any) string {
k := fmt.Sprintf("$%x", len(b))
switch v := v.(type) {
case time.Time:
@@ -120,7 +120,7 @@ const (
)
// Code implements the Node interface.
func (c Cardinality) Code() (string, []interface{}) { return string(c), nil }
func (c Cardinality) Code() (string, []any) { return string(c), nil }
// Keyword defines a Gremlin keyword.
type Keyword string
@@ -131,7 +131,7 @@ const (
)
// Code implements the Node interface.
func (k Keyword) Code() (string, []interface{}) { return string(k), nil }
func (k Keyword) Code() (string, []any) { return string(k), nil }
// Order of vertex properties.
type Order string
@@ -144,7 +144,7 @@ const (
)
// Code implements the Node interface.
func (o Order) Code() (string, []interface{}) { return string(o), nil }
func (o Order) Code() (string, []any) { return string(o), nil }
// Column references a particular type of column in a complex data structure such as a Map, a Map.Entry, or a Path.
type Column string
@@ -156,7 +156,7 @@ const (
)
// Code implements the Node interface.
func (o Column) Code() (string, []interface{}) { return string(o), nil }
func (o Column) Code() (string, []any) { return string(o), nil }
// Scope used for steps that have a variable scope which alter the manner in which the step will behave in relation to how the traverses are processed.
type Scope string
@@ -168,12 +168,12 @@ const (
)
// Code implements the Node interface.
func (s Scope) Code() (string, []interface{}) { return string(s), nil }
func (s Scope) Code() (string, []any) { return string(s), nil }
func codeList(sep string, vs ...interface{}) (string, []interface{}) {
func codeList(sep string, vs ...any) (string, []any) {
var (
br strings.Builder
args []interface{}
args []any
)
for i, node := range vs {
if i > 0 {
@@ -186,14 +186,14 @@ func codeList(sep string, vs ...interface{}) (string, []interface{}) {
return br.String(), args
}
func code(v interface{}) (string, []interface{}) {
func code(v any) (string, []any) {
switch n := v.(type) {
case Node:
return n.Code()
case *Traversal:
var (
b strings.Builder
args []interface{}
args []any
)
for i := range n.nodes {
code, nargs := n.nodes[i].Code()
@@ -202,11 +202,11 @@ func code(v interface{}) (string, []interface{}) {
}
return b.String(), args
default:
return "%s", []interface{}{v}
return "%s", []any{v}
}
}
func sface(args []string) (v []interface{}) {
func sface(args []string) (v []any) {
for _, s := range args {
v = append(v, s)
}

View File

@@ -43,14 +43,14 @@ func TestTraverse(t *testing.T) {
wantBinds: dsl.Bindings{"$0": "person", "$1": "name", "$2": "a8m"},
},
{
input: dsl.Each([]interface{}{1, 2, 3}, func(it *dsl.Traversal) *dsl.Traversal {
input: dsl.Each([]any{1, 2, 3}, func(it *dsl.Traversal) *dsl.Traversal {
return g.V(it)
}),
wantQuery: "[$0, $1, $2].each { g.V(it) }",
wantBinds: dsl.Bindings{"$0": 1, "$1": 2, "$2": 3},
},
{
input: dsl.Each([]interface{}{g.V(1).Next()}, func(it *dsl.Traversal) *dsl.Traversal {
input: dsl.Each([]any{g.V(1).Next()}, func(it *dsl.Traversal) *dsl.Traversal {
return it.ID()
}),
wantQuery: "[g.V($0).next()].each { it.id() }",
@@ -74,7 +74,7 @@ func TestTraverse(t *testing.T) {
{
input: func() *dsl.Traversal {
v1 := g.AddV("person")
each := dsl.Each([]interface{}{1, 2, 3}, func(it *dsl.Traversal) *dsl.Traversal {
each := dsl.Each([]any{1, 2, 3}, func(it *dsl.Traversal) *dsl.Traversal {
return g.V(v1).AddE("knows").To(g.V(it)).Next()
})
return dsl.Group(v1, each)

View File

@@ -7,13 +7,13 @@ package g
import "entgo.io/ent/dialect/gremlin/graph/dsl"
// V is the api for calling g.V().
func V(args ...interface{}) *dsl.Traversal { return dsl.NewTraversal().V(args...) }
func V(args ...any) *dsl.Traversal { return dsl.NewTraversal().V(args...) }
// E is the api for calling g.E().
func E(args ...interface{}) *dsl.Traversal { return dsl.NewTraversal().E(args...) }
func E(args ...any) *dsl.Traversal { return dsl.NewTraversal().E(args...) }
// AddV is the api for calling g.AddV().
func AddV(args ...interface{}) *dsl.Traversal { return dsl.NewTraversal().AddV(args...) }
func AddV(args ...any) *dsl.Traversal { return dsl.NewTraversal().AddV(args...) }
// AddE is the api for calling g.AddE().
func AddE(args ...interface{}) *dsl.Traversal { return dsl.NewTraversal().AddE(args...) }
func AddE(args ...any) *dsl.Traversal { return dsl.NewTraversal().AddE(args...) }

View File

@@ -9,37 +9,37 @@ import (
)
// EQ is the equal predicate.
func EQ(v interface{}) *dsl.Traversal {
func EQ(v any) *dsl.Traversal {
return op("eq", v)
}
// NEQ is the not-equal predicate.
func NEQ(v interface{}) *dsl.Traversal {
func NEQ(v any) *dsl.Traversal {
return op("neq", v)
}
// GT is the greater than predicate.
func GT(v interface{}) *dsl.Traversal {
func GT(v any) *dsl.Traversal {
return op("gt", v)
}
// GTE is the greater than or equal predicate.
func GTE(v interface{}) *dsl.Traversal {
func GTE(v any) *dsl.Traversal {
return op("gte", v)
}
// LT is the less than predicate.
func LT(v interface{}) *dsl.Traversal {
func LT(v any) *dsl.Traversal {
return op("lt", v)
}
// LTE is the less than or equal predicate.
func LTE(v interface{}) *dsl.Traversal {
func LTE(v any) *dsl.Traversal {
return op("lte", v)
}
// Between is the between/contains predicate.
func Between(v, u interface{}) *dsl.Traversal {
func Between(v, u any) *dsl.Traversal {
return op("between", v, u)
}
@@ -74,16 +74,16 @@ func NotContaining(substr string) *dsl.Traversal {
}
// Within Determines if a value is within the specified list of values.
func Within(args ...interface{}) *dsl.Traversal {
func Within(args ...any) *dsl.Traversal {
return op("within", args...)
}
// Without determines if a value is not within the specified list of values.
func Without(args ...interface{}) *dsl.Traversal {
func Without(args ...any) *dsl.Traversal {
return op("without", args...)
}
func op(name string, args ...interface{}) *dsl.Traversal {
func op(name string, args ...any) *dsl.Traversal {
t := &dsl.Traversal{}
return t.Add(dsl.NewFunc(name, args...))
}

View File

@@ -55,7 +55,7 @@ func Join(trs ...*Traversal) *Traversal {
}
// V step is usually used to start a traversal but it may also be used mid-traversal.
func (t *Traversal) V(args ...interface{}) *Traversal {
func (t *Traversal) V(args ...any) *Traversal {
t.Add(Dot, NewFunc("V", args...))
return t
}
@@ -67,19 +67,19 @@ func (t *Traversal) OtherV() *Traversal {
}
// E step is usually used to start a traversal but it may also be used mid-traversal.
func (t *Traversal) E(args ...interface{}) *Traversal {
func (t *Traversal) E(args ...any) *Traversal {
t.Add(Dot, NewFunc("E", args...))
return t
}
// AddV adds a vertex.
func (t *Traversal) AddV(args ...interface{}) *Traversal {
func (t *Traversal) AddV(args ...any) *Traversal {
t.Add(Dot, NewFunc("addV", args...))
return t
}
// AddE adds an edge.
func (t *Traversal) AddE(args ...interface{}) *Traversal {
func (t *Traversal) AddE(args ...any) *Traversal {
t.Add(Dot, NewFunc("addE", args...))
return t
}
@@ -96,39 +96,39 @@ func (t *Traversal) Drop() *Traversal {
// Property sets a Property value and related meta properties if supplied,
// if supported by the Graph and if the Element is a VertexProperty.
func (t *Traversal) Property(args ...interface{}) *Traversal {
func (t *Traversal) Property(args ...any) *Traversal {
return t.Add(Dot, NewFunc("property", args...))
}
// Both maps the Vertex to its adjacent vertices given the edge labels.
func (t *Traversal) Both(args ...interface{}) *Traversal {
func (t *Traversal) Both(args ...any) *Traversal {
return t.Add(Dot, NewFunc("both", args...))
}
// BothE maps the Vertex to its incident edges given the edge labels.
func (t *Traversal) BothE(args ...interface{}) *Traversal {
func (t *Traversal) BothE(args ...any) *Traversal {
return t.Add(Dot, NewFunc("bothE", args...))
}
// Has filters vertices, edges and vertex properties based on their properties.
// See: http://tinkerpop.apache.org/docs/current/reference/#has-step.
func (t *Traversal) Has(args ...interface{}) *Traversal {
func (t *Traversal) Has(args ...any) *Traversal {
return t.Add(Dot, NewFunc("has", args...))
}
// HasNot filters vertices, edges and vertex properties based on the non-existence of properties.
// See: http://tinkerpop.apache.org/docs/current/reference/#has-step.
func (t *Traversal) HasNot(args ...interface{}) *Traversal {
func (t *Traversal) HasNot(args ...any) *Traversal {
return t.Add(Dot, NewFunc("hasNot", args...))
}
// HasID filters vertices, edges and vertex properties based on their identifier.
func (t *Traversal) HasID(args ...interface{}) *Traversal {
func (t *Traversal) HasID(args ...any) *Traversal {
return t.Add(Dot, NewFunc("hasId", args...))
}
// HasLabel filters vertices, edges and vertex properties based on their label.
func (t *Traversal) HasLabel(args ...interface{}) *Traversal {
func (t *Traversal) HasLabel(args ...any) *Traversal {
return t.Add(Dot, NewFunc("hasLabel", args...))
}
@@ -138,17 +138,17 @@ func (t *Traversal) HasNext() *Traversal {
}
// Match maps the Traverser to a Map of bindings as specified by the provided match traversals.
func (t *Traversal) Match(args ...interface{}) *Traversal {
func (t *Traversal) Match(args ...any) *Traversal {
return t.Add(Dot, NewFunc("match", args...))
}
// Choose routes the current traverser to a particular traversal branch option which allows the creation of if-then-else like semantics within a traversal.
func (t *Traversal) Choose(args ...interface{}) *Traversal {
func (t *Traversal) Choose(args ...any) *Traversal {
return t.Add(Dot, NewFunc("choose", args...))
}
// Select arbitrary values from the traversal.
func (t *Traversal) Select(args ...interface{}) *Traversal {
func (t *Traversal) Select(args ...any) *Traversal {
return t.Add(Dot, NewFunc("select", args...))
}
@@ -163,22 +163,22 @@ func (t *Traversal) Values(args ...string) *Traversal {
}
// ValueMap maps the Element to a Map of the property values key'd according to their Property.key().
func (t *Traversal) ValueMap(args ...interface{}) *Traversal {
func (t *Traversal) ValueMap(args ...any) *Traversal {
return t.Add(Dot, NewFunc("valueMap", args...))
}
// Properties maps the Element to its associated properties given the provide property keys.
func (t *Traversal) Properties(args ...interface{}) *Traversal {
func (t *Traversal) Properties(args ...any) *Traversal {
return t.Add(Dot, NewFunc("properties", args...))
}
// Range filters the objects in the traversal by the number of them to pass through the stream.
func (t *Traversal) Range(args ...interface{}) *Traversal {
func (t *Traversal) Range(args ...any) *Traversal {
return t.Add(Dot, NewFunc("range", args...))
}
// Limit filters the objects in the traversal by the number of them to pass through the stream, where only the first n objects are allowed as defined by the limit argument.
func (t *Traversal) Limit(args ...interface{}) *Traversal {
func (t *Traversal) Limit(args ...any) *Traversal {
return t.Add(Dot, NewFunc("limit", args...))
}
@@ -193,72 +193,72 @@ func (t *Traversal) Label() *Traversal {
}
// From provides from()-modulation to respective steps.
func (t *Traversal) From(args ...interface{}) *Traversal {
func (t *Traversal) From(args ...any) *Traversal {
return t.Add(Dot, NewFunc("from", args...))
}
// To used as a modifier to addE(String) this method specifies the traversal to use for selecting the incoming vertex of the newly added Edge.
func (t *Traversal) To(args ...interface{}) *Traversal {
func (t *Traversal) To(args ...any) *Traversal {
return t.Add(Dot, NewFunc("to", args...))
}
// As provides a label to the step that can be accessed later in the traversal by other steps.
func (t *Traversal) As(args ...interface{}) *Traversal {
func (t *Traversal) As(args ...any) *Traversal {
return t.Add(Dot, NewFunc("as", args...))
}
// Or ensures that at least one of the provided traversals yield a result.
func (t *Traversal) Or(args ...interface{}) *Traversal {
func (t *Traversal) Or(args ...any) *Traversal {
return t.Add(Dot, NewFunc("or", args...))
}
// And ensures that all of the provided traversals yield a result.
func (t *Traversal) And(args ...interface{}) *Traversal {
func (t *Traversal) And(args ...any) *Traversal {
return t.Add(Dot, NewFunc("and", args...))
}
// Is filters the E object if it is not P.eq(V) to the provided value.
func (t *Traversal) Is(args ...interface{}) *Traversal {
func (t *Traversal) Is(args ...any) *Traversal {
return t.Add(Dot, NewFunc("is", args...))
}
// Not removes objects from the traversal stream when the traversal provided as an argument does not return any objects.
func (t *Traversal) Not(args ...interface{}) *Traversal {
func (t *Traversal) Not(args ...any) *Traversal {
return t.Add(Dot, NewFunc("not", args...))
}
// In maps the Vertex to its incoming adjacent vertices given the edge labels.
func (t *Traversal) In(args ...interface{}) *Traversal {
func (t *Traversal) In(args ...any) *Traversal {
return t.Add(Dot, NewFunc("in", args...))
}
// Where filters the current object based on the object itself or the path history.
func (t *Traversal) Where(args ...interface{}) *Traversal {
func (t *Traversal) Where(args ...any) *Traversal {
return t.Add(Dot, NewFunc("where", args...))
}
// Out maps the Vertex to its outgoing adjacent vertices given the edge labels.
func (t *Traversal) Out(args ...interface{}) *Traversal {
func (t *Traversal) Out(args ...any) *Traversal {
return t.Add(Dot, NewFunc("out", args...))
}
// OutE maps the Vertex to its outgoing incident edges given the edge labels.
func (t *Traversal) OutE(args ...interface{}) *Traversal {
func (t *Traversal) OutE(args ...any) *Traversal {
return t.Add(Dot, NewFunc("outE", args...))
}
// InE maps the Vertex to its incoming incident edges given the edge labels.
func (t *Traversal) InE(args ...interface{}) *Traversal {
func (t *Traversal) InE(args ...any) *Traversal {
return t.Add(Dot, NewFunc("inE", args...))
}
// OutV maps the Edge to its outgoing/tail incident Vertex.
func (t *Traversal) OutV(args ...interface{}) *Traversal {
func (t *Traversal) OutV(args ...any) *Traversal {
return t.Add(Dot, NewFunc("outV", args...))
}
// InV maps the Edge to its incoming/head incident Vertex.
func (t *Traversal) InV(args ...interface{}) *Traversal {
func (t *Traversal) InV(args ...any) *Traversal {
return t.Add(Dot, NewFunc("inV", args...))
}
@@ -274,18 +274,18 @@ func (t *Traversal) Iterate() *Traversal {
// Count maps the traversal stream to its reduction as a sum of the Traverser.bulk() values
// (i.e. count the number of traversers up to this point).
func (t *Traversal) Count(args ...interface{}) *Traversal {
func (t *Traversal) Count(args ...any) *Traversal {
return t.Add(Dot, NewFunc("count", args...))
}
// Order all the objects in the traversal up to this point and then emit them one-by-one in their ordered sequence.
func (t *Traversal) Order(args ...interface{}) *Traversal {
func (t *Traversal) Order(args ...any) *Traversal {
return t.Add(Dot, NewFunc("order", args...))
}
// By can be applied to a number of different step to alter their behaviors.
// This form is essentially an identity() modulation.
func (t *Traversal) By(args ...interface{}) *Traversal {
func (t *Traversal) By(args ...any) *Traversal {
return t.Add(Dot, NewFunc("by", args...))
}
@@ -300,58 +300,58 @@ func (t *Traversal) Unfold() *Traversal {
}
// Sum maps the traversal stream to its reduction as a sum of the Traverser.get() values multiplied by their Traverser.bulk().
func (t *Traversal) Sum(args ...interface{}) *Traversal {
func (t *Traversal) Sum(args ...any) *Traversal {
return t.Add(Dot, NewFunc("sum", args...))
}
// Mean determines the mean value in the stream.
func (t *Traversal) Mean(args ...interface{}) *Traversal {
func (t *Traversal) Mean(args ...any) *Traversal {
return t.Add(Dot, NewFunc("mean", args...))
}
// Min determines the smallest value in the stream.
func (t *Traversal) Min(args ...interface{}) *Traversal {
func (t *Traversal) Min(args ...any) *Traversal {
return t.Add(Dot, NewFunc("min", args...))
}
// Max determines the greatest value in the stream.
func (t *Traversal) Max(args ...interface{}) *Traversal {
func (t *Traversal) Max(args ...any) *Traversal {
return t.Add(Dot, NewFunc("max", args...))
}
// Coalesce evaluates the provided traversals and returns the result of the first traversal to emit at least one object.
func (t *Traversal) Coalesce(args ...interface{}) *Traversal {
func (t *Traversal) Coalesce(args ...any) *Traversal {
return t.Add(Dot, NewFunc("coalesce", args...))
}
// Dedup removes all duplicates in the traversal stream up to this point.
func (t *Traversal) Dedup(args ...interface{}) *Traversal {
func (t *Traversal) Dedup(args ...any) *Traversal {
return t.Add(Dot, NewFunc("dedup", args...))
}
// Constant maps any object to a fixed E value.
func (t *Traversal) Constant(args ...interface{}) *Traversal {
func (t *Traversal) Constant(args ...any) *Traversal {
return t.Add(Dot, NewFunc("constant", args...))
}
// Union merges the results of an arbitrary number of traversals.
func (t *Traversal) Union(args ...interface{}) *Traversal {
func (t *Traversal) Union(args ...any) *Traversal {
return t.Add(Dot, NewFunc("union", args...))
}
// SideEffect allows the traverser to proceed unchanged, but yield some computational
// sideEffect in the process.
func (t *Traversal) SideEffect(args ...interface{}) *Traversal {
func (t *Traversal) SideEffect(args ...any) *Traversal {
return t.Add(Dot, NewFunc("sideEffect", args...))
}
// Each is a Groovy each-loop function.
func Each(v interface{}, cb func(it *Traversal) *Traversal) *Traversal {
func Each(v any, cb func(it *Traversal) *Traversal) *Traversal {
t := &Traversal{}
switch v := v.(type) {
case *Traversal:
t.Add(&Var{Elem: v})
case []interface{}:
case []any:
t.Add(NewList(v...))
default:
t.Add(Token("undefined"))
@@ -371,7 +371,7 @@ func (t *Traversal) Add(n ...Node) *Traversal {
// Query returns the query-representation and its binding of this traversal object.
func (t *Traversal) Query() (string, Bindings) {
var (
names []interface{}
names []any
query strings.Builder
bindings = Bindings{}
)

View File

@@ -20,15 +20,15 @@ type (
// graphson edge repr.
edge struct {
Element
OutV interface{} `json:"outV"`
OutVLabel string `json:"outVLabel"`
InV interface{} `json:"inV"`
InVLabel string `json:"inVLabel"`
OutV any `json:"outV"`
OutVLabel string `json:"outVLabel"`
InV any `json:"inV"`
InVLabel string `json:"inVLabel"`
}
)
// NewEdge create a new graph edge.
func NewEdge(id interface{}, label string, outV, inV Vertex) Edge {
func NewEdge(id any, label string, outV, inV Vertex) Edge {
return Edge{
Element: NewElement(id, label),
OutV: outV,
@@ -74,12 +74,12 @@ func (edge) GraphsonType() graphson.Type {
// Property denotes a key/value pair associated with an edge.
type Property struct {
Key string `json:"key"`
Value interface{} `json:"value"`
Key string `json:"key"`
Value any `json:"value"`
}
// NewProperty create a new graph edge property.
func NewProperty(key string, value interface{}) Property {
func NewProperty(key string, value any) Property {
return Property{key, value}
}

View File

@@ -6,11 +6,11 @@ package graph
// Element defines a base struct for graph elements.
type Element struct {
ID interface{} `json:"id"`
Label string `json:"label"`
ID any `json:"id"`
Label string `json:"label"`
}
// NewElement create a new graph element.
func NewElement(id interface{}, label string) Element {
func NewElement(id any, label string) Element {
return Element{id, label}
}

View File

@@ -13,10 +13,10 @@ import (
)
// ValueMap models a .valueMap() gremlin response.
type ValueMap []map[string]interface{}
type ValueMap []map[string]any
// Decode decodes a value map into v.
func (m ValueMap) Decode(v interface{}) error {
func (m ValueMap) Decode(v any) error {
rv := reflect.ValueOf(v)
if rv.Kind() != reflect.Ptr {
return errors.New("cannot unmarshal into a non pointer")
@@ -26,14 +26,14 @@ func (m ValueMap) Decode(v interface{}) error {
}
if rv.Elem().Kind() != reflect.Slice {
v = &[]interface{}{v}
v = &[]any{v}
}
return m.decode(v)
}
func (m ValueMap) decode(v interface{}) error {
func (m ValueMap) decode(v any) error {
cfg := mapstructure.DecoderConfig{
DecodeHook: func(f, t reflect.Kind, data interface{}) (interface{}, error) {
DecodeHook: func(f, t reflect.Kind, data any) (any, error) {
if f == reflect.Slice && t != reflect.Slice {
rv := reflect.ValueOf(data)
if rv.Len() == 1 {

View File

@@ -12,11 +12,11 @@ import (
)
func TestValueMapDecodeOne(t *testing.T) {
vm := ValueMap{map[string]interface{}{
vm := ValueMap{map[string]any{
"id": int64(1),
"label": "person",
"name": []interface{}{"marko"},
"age": []interface{}{int32(29)},
"name": []any{"marko"},
"age": []any{int32(29)},
}}
var ent struct {
@@ -36,15 +36,15 @@ func TestValueMapDecodeOne(t *testing.T) {
func TestValueMapDecodeMany(t *testing.T) {
vm := ValueMap{
map[string]interface{}{
map[string]any{
"id": int64(1),
"label": "person",
"name": []interface{}{"chico"},
"name": []any{"chico"},
},
map[string]interface{}{
map[string]any{
"id": int64(2),
"label": "person",
"name": []interface{}{"dico"},
"name": []any{"dico"},
},
}

View File

@@ -16,7 +16,7 @@ type Vertex struct {
}
// NewVertex create a new graph vertex.
func NewVertex(id interface{}, label string) Vertex {
func NewVertex(id any, label string) Vertex {
if label == "" {
label = "vertex"
}
@@ -37,13 +37,13 @@ func (v Vertex) String() string {
// VertexProperty denotes a key/value pair associated with a vertex.
type VertexProperty struct {
ID interface{} `json:"id"`
Key string `json:"label"`
Value interface{} `json:"value"`
ID any `json:"id"`
Key string `json:"label"`
Value any `json:"value"`
}
// NewVertexProperty create a new graph vertex property.
func NewVertexProperty(id interface{}, key string, value interface{}) VertexProperty {
func NewVertexProperty(id any, key string, value any) VertexProperty {
return VertexProperty{
ID: id,
Key: key,