diff --git a/algo/packed_test.go b/algo/packed_test.go index 3c566889524..b3e33f81486 100644 --- a/algo/packed_test.go +++ b/algo/packed_test.go @@ -20,9 +20,10 @@ import ( "math" "testing" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgraph/codec" "github.com/dgraph-io/dgraph/protos/pb" - "github.com/stretchr/testify/require" ) func newUidPack(data []uint64) *pb.UidPack { diff --git a/algo/uidlist_test.go b/algo/uidlist_test.go index bb8921f7426..849ea1f6222 100644 --- a/algo/uidlist_test.go +++ b/algo/uidlist_test.go @@ -23,9 +23,10 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgraph/codec" "github.com/dgraph-io/dgraph/protos/pb" - "github.com/stretchr/testify/require" ) func newList(data []uint64) *pb.List { diff --git a/chunker/chunk.go b/chunker/chunk.go index 486866d048f..ae2fffbf7ca 100644 --- a/chunker/chunk.go +++ b/chunker/chunk.go @@ -28,11 +28,11 @@ import ( "strings" "unicode" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/ee/enc" "github.com/dgraph-io/dgraph/lex" "github.com/dgraph-io/dgraph/x" - - "github.com/pkg/errors" ) // Chunker describes the interface to parse and process the input to the live and bulk loaders. diff --git a/chunker/json_parser.go b/chunker/json_parser.go index 28085ee0aaf..b4a172547d8 100644 --- a/chunker/json_parser.go +++ b/chunker/json_parser.go @@ -26,15 +26,16 @@ import ( "sync/atomic" "unicode" + "github.com/pkg/errors" + geom "github.com/twpayne/go-geom" + "github.com/twpayne/go-geom/encoding/geojson" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/types/facets" "github.com/dgraph-io/dgraph/x" simdjson "github.com/dgraph-io/simdjson-go" - "github.com/pkg/errors" - geom "github.com/twpayne/go-geom" - "github.com/twpayne/go-geom/encoding/geojson" ) func stripSpaces(str string) string { diff --git a/chunker/json_parser_test.go b/chunker/json_parser_test.go index 600c8cba907..7a328852edb 100644 --- a/chunker/json_parser_test.go +++ b/chunker/json_parser_test.go @@ -25,13 +25,13 @@ import ( "testing" "time" - "github.com/dgraph-io/dgraph/testutil" - "github.com/dgraph-io/dgraph/tok" "github.com/golang/glog" + "github.com/stretchr/testify/require" "github.com/dgraph-io/dgo/v210/protos/api" + "github.com/dgraph-io/dgraph/testutil" + "github.com/dgraph-io/dgraph/tok" "github.com/dgraph-io/dgraph/types" - "github.com/stretchr/testify/require" ) func makeNquad(sub, pred string, val *api.Value) *api.NQuad { diff --git a/chunker/rdf_parser.go b/chunker/rdf_parser.go index 47a854754d7..14240043068 100644 --- a/chunker/rdf_parser.go +++ b/chunker/rdf_parser.go @@ -22,13 +22,14 @@ import ( "strings" "unicode" + "github.com/pkg/errors" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/lex" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/types/facets" "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" ) var ( diff --git a/chunker/rdf_parser_test.go b/chunker/rdf_parser_test.go index 0c55da19cf9..2978bdffdf1 100644 --- a/chunker/rdf_parser_test.go +++ b/chunker/rdf_parser_test.go @@ -19,11 +19,12 @@ package chunker import ( "testing" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/lex" "github.com/dgraph-io/dgraph/types/facets" "github.com/dgraph-io/dgraph/x" - "github.com/stretchr/testify/require" ) var testNQuads = []struct { diff --git a/chunker/rdf_state.go b/chunker/rdf_state.go index e3dcf411146..7e082de9fdf 100644 --- a/chunker/rdf_state.go +++ b/chunker/rdf_state.go @@ -364,7 +364,8 @@ func lexLabel(l *lex.Lexer) lex.StateFn { // lexFacets parses key-value pairs of Facets. sample is : // ( key1 = "value1", key2=13, key3=, key4 =2.4, key5=2006-01-02T15:04:05, -// key6=2006-01-02 ) +// +// key6=2006-01-02 ) func lexFacets(l *lex.Lexer) lex.StateFn { r := l.Next() if r != leftRound { diff --git a/codec/codec.go b/codec/codec.go index 4246913d102..76314aecf95 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -23,10 +23,11 @@ import ( "sort" "unsafe" + "github.com/dgryski/go-groupvarint" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - "github.com/dgryski/go-groupvarint" ) type seekPos int diff --git a/codec/codec_test.go b/codec/codec_test.go index b5f7b6b7038..ca0c6b7747b 100644 --- a/codec/codec_test.go +++ b/codec/codec_test.go @@ -26,11 +26,12 @@ import ( "testing" "time" + humanize "github.com/dustin/go-humanize" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - humanize "github.com/dustin/go-humanize" - "github.com/stretchr/testify/require" ) func getUids(size int) []uint64 { diff --git a/conn/node_test.go b/conn/node_test.go index e9c5463e4b2..11ee83489a6 100644 --- a/conn/node_test.go +++ b/conn/node_test.go @@ -26,11 +26,12 @@ import ( "testing" "time" - "github.com/dgraph-io/dgraph/protos/pb" - "github.com/dgraph-io/dgraph/raftwal" "github.com/stretchr/testify/require" "go.etcd.io/etcd/raft" "go.etcd.io/etcd/raft/raftpb" + + "github.com/dgraph-io/dgraph/protos/pb" + "github.com/dgraph-io/dgraph/raftwal" ) func (n *Node) run(wg *sync.WaitGroup) { diff --git a/conn/pool.go b/conn/pool.go index 74535f4c19e..26eb85d11b3 100644 --- a/conn/pool.go +++ b/conn/pool.go @@ -23,16 +23,16 @@ import ( "sync" "time" - "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/dgraph/protos/pb" - "github.com/dgraph-io/dgraph/x" - "github.com/dgraph-io/ristretto/z" "github.com/golang/glog" "github.com/pkg/errors" "go.opencensus.io/plugin/ocgrpc" - "google.golang.org/grpc" "google.golang.org/grpc/credentials" + + "github.com/dgraph-io/dgo/v210/protos/api" + "github.com/dgraph-io/dgraph/protos/pb" + "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" ) var ( diff --git a/conn/raft_server.go b/conn/raft_server.go index 5c360ef9b1c..534d439925f 100644 --- a/conn/raft_server.go +++ b/conn/raft_server.go @@ -25,13 +25,14 @@ import ( "sync/atomic" "time" - "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/dgraph/protos/pb" - "github.com/dgraph-io/dgraph/x" "github.com/golang/glog" "github.com/pkg/errors" "go.etcd.io/etcd/raft/raftpb" otrace "go.opencensus.io/trace" + + "github.com/dgraph-io/dgo/v210/protos/api" + "github.com/dgraph-io/dgraph/protos/pb" + "github.com/dgraph-io/dgraph/x" ) type sendmsg struct { diff --git a/contrib/integration/bank/main.go b/contrib/integration/bank/main.go index b70fd84ca12..4dbeb060f47 100644 --- a/contrib/integration/bank/main.go +++ b/contrib/integration/bank/main.go @@ -35,11 +35,12 @@ import ( "sync/atomic" "time" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/x" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials" ) var ( diff --git a/contrib/integration/bigdata/main.go b/contrib/integration/bigdata/main.go index 2200a5c4994..85d5c9b5a96 100644 --- a/contrib/integration/bigdata/main.go +++ b/contrib/integration/bigdata/main.go @@ -28,10 +28,11 @@ import ( "sync/atomic" "time" + "google.golang.org/grpc" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/x" - "google.golang.org/grpc" ) var addrs = flag.String("addrs", "", "comma separated dgraph addresses") diff --git a/contrib/integration/mutates/main.go b/contrib/integration/mutates/main.go index 8a1c1e35a68..f5f3558234f 100644 --- a/contrib/integration/mutates/main.go +++ b/contrib/integration/mutates/main.go @@ -23,10 +23,11 @@ import ( "fmt" "log" + "google.golang.org/grpc" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/x" - "google.golang.org/grpc" ) var alpha = flag.String("alpha", "localhost:9080", "Dgraph alpha addr") diff --git a/contrib/integration/swap/main.go b/contrib/integration/swap/main.go index 085279b4cec..f3433fc608e 100644 --- a/contrib/integration/swap/main.go +++ b/contrib/integration/swap/main.go @@ -28,11 +28,12 @@ import ( "sync/atomic" "time" + "github.com/pkg/errors" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" ) var ( diff --git a/contrib/integration/testtxn/main_test.go b/contrib/integration/testtxn/main_test.go index 96757338c81..d90052e24a8 100644 --- a/contrib/integration/testtxn/main_test.go +++ b/contrib/integration/testtxn/main_test.go @@ -29,12 +29,13 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) type state struct { diff --git a/contrib/jepsen/main.go b/contrib/jepsen/main.go index e3b8fa1e5a0..c4d9b08bb17 100644 --- a/contrib/jepsen/main.go +++ b/contrib/jepsen/main.go @@ -43,8 +43,9 @@ import ( "sync" "time" - "github.com/dgraph-io/dgraph/contrib/jepsen/browser" "github.com/spf13/pflag" + + "github.com/dgraph-io/dgraph/contrib/jepsen/browser" ) type jepsenTest struct { diff --git a/dgraph/cmd/alpha/admin.go b/dgraph/cmd/alpha/admin.go index 7768e2c6d08..7e66e4e9181 100644 --- a/dgraph/cmd/alpha/admin.go +++ b/dgraph/cmd/alpha/admin.go @@ -25,7 +25,6 @@ import ( "strings" "github.com/dgraph-io/dgraph/graphql/admin" - "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" diff --git a/dgraph/cmd/alpha/admin_backup.go b/dgraph/cmd/alpha/admin_backup.go index 323caa07918..4754e722aa2 100644 --- a/dgraph/cmd/alpha/admin_backup.go +++ b/dgraph/cmd/alpha/admin_backup.go @@ -1,3 +1,4 @@ +//go:build !oss // +build !oss /* @@ -21,10 +22,10 @@ package alpha import ( "net/http" - "github.com/dgraph-io/dgraph/graphql/schema" + "github.com/golang/glog" + "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" ) func init() { diff --git a/dgraph/cmd/alpha/http.go b/dgraph/cmd/alpha/http.go index 3b36ac93ee7..cb5dcbe9cf7 100644 --- a/dgraph/cmd/alpha/http.go +++ b/dgraph/cmd/alpha/http.go @@ -32,18 +32,18 @@ import ( "sync/atomic" "time" - "github.com/dgraph-io/dgraph/graphql/admin" + "github.com/gogo/protobuf/jsonpb" + "github.com/golang/glog" + "github.com/pkg/errors" + "google.golang.org/grpc/metadata" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/dql" "github.com/dgraph-io/dgraph/edgraph" + "github.com/dgraph-io/dgraph/graphql/admin" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/query" "github.com/dgraph-io/dgraph/x" - "github.com/gogo/protobuf/jsonpb" - "github.com/golang/glog" - "github.com/pkg/errors" - "google.golang.org/grpc/metadata" ) func allowed(method string) bool { diff --git a/dgraph/cmd/alpha/login_ee.go b/dgraph/cmd/alpha/login_ee.go index ec6432631e4..d04e32a29a8 100644 --- a/dgraph/cmd/alpha/login_ee.go +++ b/dgraph/cmd/alpha/login_ee.go @@ -1,3 +1,4 @@ +//go:build !oss // +build !oss /* @@ -17,10 +18,11 @@ import ( "encoding/json" "net/http" + "github.com/golang/glog" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/edgraph" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" ) func loginHandler(w http.ResponseWriter, r *http.Request) { diff --git a/dgraph/cmd/alpha/mutations_mode/mutations_mode_test.go b/dgraph/cmd/alpha/mutations_mode/mutations_mode_test.go index d380de59183..a389a6859e2 100644 --- a/dgraph/cmd/alpha/mutations_mode/mutations_mode_test.go +++ b/dgraph/cmd/alpha/mutations_mode/mutations_mode_test.go @@ -21,12 +21,12 @@ import ( "strings" "testing" + "github.com/stretchr/testify/require" + "google.golang.org/grpc" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" - "github.com/stretchr/testify/require" - - "google.golang.org/grpc" ) // Tests in this file require a cluster running with the --limit "mutations=;" flag. diff --git a/dgraph/cmd/alpha/run.go b/dgraph/cmd/alpha/run.go index 4a9795d476a..62846356d54 100644 --- a/dgraph/cmd/alpha/run.go +++ b/dgraph/cmd/alpha/run.go @@ -25,8 +25,6 @@ import ( "math" "net" "net/http" - - //nolint:gosec // profiling on alpha server accepted and documented _ "net/http/pprof" // http profiler "net/url" "os" @@ -37,20 +35,6 @@ import ( "syscall" "time" - "github.com/dgraph-io/badger/v3" - "github.com/dgraph-io/dgraph/ee" - "github.com/dgraph-io/dgraph/ee/audit" - - "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/dgraph/edgraph" - "github.com/dgraph-io/dgraph/ee/enc" - "github.com/dgraph-io/dgraph/graphql/admin" - "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/schema" - "github.com/dgraph-io/dgraph/tok" - "github.com/dgraph-io/dgraph/worker" - "github.com/dgraph-io/dgraph/x" - "github.com/dgraph-io/ristretto/z" "github.com/golang/glog" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -64,7 +48,20 @@ import ( "google.golang.org/grpc/health" hapi "google.golang.org/grpc/health/grpc_health_v1" + "github.com/dgraph-io/badger/v3" + "github.com/dgraph-io/dgo/v210/protos/api" + "github.com/dgraph-io/dgraph/edgraph" + "github.com/dgraph-io/dgraph/ee" + "github.com/dgraph-io/dgraph/ee/audit" + "github.com/dgraph-io/dgraph/ee/enc" + "github.com/dgraph-io/dgraph/graphql/admin" + "github.com/dgraph-io/dgraph/posting" + "github.com/dgraph-io/dgraph/schema" + "github.com/dgraph-io/dgraph/tok" + "github.com/dgraph-io/dgraph/worker" + "github.com/dgraph-io/dgraph/x" _ "github.com/dgraph-io/gqlparser/v2/validator/rules" // make gql validator init() all rules + "github.com/dgraph-io/ristretto/z" ) var ( diff --git a/dgraph/cmd/alpha/run_test.go b/dgraph/cmd/alpha/run_test.go index 8347e42a95b..5fa5454d683 100644 --- a/dgraph/cmd/alpha/run_test.go +++ b/dgraph/cmd/alpha/run_test.go @@ -31,14 +31,6 @@ import ( "testing" "time" - "github.com/dgraph-io/dgo/v210" - "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/dgraph/dql" - "github.com/dgraph-io/dgraph/protos/pb" - "github.com/dgraph-io/dgraph/query" - "github.com/dgraph-io/dgraph/schema" - "github.com/dgraph-io/dgraph/testutil" - "github.com/dgraph-io/dgraph/x" "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -47,6 +39,15 @@ import ( "github.com/twpayne/go-geom/encoding/wkb" "google.golang.org/grpc" "google.golang.org/grpc/encoding/gzip" + + "github.com/dgraph-io/dgo/v210" + "github.com/dgraph-io/dgo/v210/protos/api" + "github.com/dgraph-io/dgraph/dql" + "github.com/dgraph-io/dgraph/protos/pb" + "github.com/dgraph-io/dgraph/query" + "github.com/dgraph-io/dgraph/schema" + "github.com/dgraph-io/dgraph/testutil" + "github.com/dgraph-io/dgraph/x" ) type defaultContextKey int diff --git a/dgraph/cmd/alpha/upsert_test.go b/dgraph/cmd/alpha/upsert_test.go index 28d756a1c5e..fd85a399739 100644 --- a/dgraph/cmd/alpha/upsert_test.go +++ b/dgraph/cmd/alpha/upsert_test.go @@ -24,11 +24,12 @@ import ( "sync" "testing" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" - "github.com/stretchr/testify/require" ) type QueryResult struct { diff --git a/dgraph/cmd/bulk/loader.go b/dgraph/cmd/bulk/loader.go index 9c0f7afcde9..45faef40692 100644 --- a/dgraph/cmd/bulk/loader.go +++ b/dgraph/cmd/bulk/loader.go @@ -33,11 +33,11 @@ import ( "sync" "time" + "google.golang.org/grpc" "google.golang.org/grpc/credentials" "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/badger/v3/y" - "github.com/dgraph-io/dgraph/chunker" "github.com/dgraph-io/dgraph/ee/enc" "github.com/dgraph-io/dgraph/filestore" @@ -45,8 +45,6 @@ import ( "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/dgraph/xidmap" - - "google.golang.org/grpc" ) type options struct { diff --git a/dgraph/cmd/bulk/mapper.go b/dgraph/cmd/bulk/mapper.go index 85523c1f6ff..e7a73e190c0 100644 --- a/dgraph/cmd/bulk/mapper.go +++ b/dgraph/cmd/bulk/mapper.go @@ -29,6 +29,9 @@ import ( "sync" "sync/atomic" + farm "github.com/dgryski/go-farm" + "github.com/golang/snappy" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/chunker" "github.com/dgraph-io/dgraph/dql" @@ -39,8 +42,6 @@ import ( "github.com/dgraph-io/dgraph/types/facets" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - farm "github.com/dgryski/go-farm" - "github.com/golang/snappy" ) type mapper struct { diff --git a/dgraph/cmd/bulk/progress.go b/dgraph/cmd/bulk/progress.go index 8bbf864769c..ebdb7fd57ba 100644 --- a/dgraph/cmd/bulk/progress.go +++ b/dgraph/cmd/bulk/progress.go @@ -21,9 +21,10 @@ import ( "sync/atomic" "time" + "github.com/dustin/go-humanize" + "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - "github.com/dustin/go-humanize" ) type phase int32 diff --git a/dgraph/cmd/bulk/reduce.go b/dgraph/cmd/bulk/reduce.go index b5094dd5b34..192b681ed7b 100644 --- a/dgraph/cmd/bulk/reduce.go +++ b/dgraph/cmd/bulk/reduce.go @@ -34,6 +34,9 @@ import ( "sync/atomic" "time" + "github.com/dustin/go-humanize" + "github.com/golang/snappy" + "github.com/dgraph-io/badger/v3" bo "github.com/dgraph-io/badger/v3/options" bpb "github.com/dgraph-io/badger/v3/pb" @@ -43,8 +46,6 @@ import ( "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - "github.com/dustin/go-humanize" - "github.com/golang/snappy" ) type reducer struct { diff --git a/dgraph/cmd/bulk/run.go b/dgraph/cmd/bulk/run.go index 26d1359a5ff..9a16d8ed00e 100644 --- a/dgraph/cmd/bulk/run.go +++ b/dgraph/cmd/bulk/run.go @@ -23,8 +23,6 @@ import ( "log" "math" "net/http" - - //nolint:gosec // profiling on bulk-loader tool considered noncritical _ "net/http/pprof" // http profiler "os" "path/filepath" @@ -32,16 +30,16 @@ import ( "strconv" "strings" + "github.com/spf13/cobra" + "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/dgraph/ee" "github.com/dgraph-io/dgraph/filestore" "github.com/dgraph-io/dgraph/protos/pb" - "github.com/dgraph-io/dgraph/worker" - "github.com/dgraph-io/ristretto/z" - "github.com/dgraph-io/dgraph/tok" + "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" - "github.com/spf13/cobra" + "github.com/dgraph-io/ristretto/z" ) // Bulk is the sub-command invoked when running "dgraph bulk". diff --git a/dgraph/cmd/cert/info.go b/dgraph/cmd/cert/info.go index c2a65a1fb2c..e38cc6a2669 100644 --- a/dgraph/cmd/cert/info.go +++ b/dgraph/cmd/cert/info.go @@ -29,8 +29,9 @@ import ( "strings" "time" - "github.com/dgraph-io/dgraph/x" "github.com/pkg/errors" + + "github.com/dgraph-io/dgraph/x" ) type certInfo struct { diff --git a/dgraph/cmd/cert/run.go b/dgraph/cmd/cert/run.go index 01cf72df4ce..5a35b6bf4cb 100644 --- a/dgraph/cmd/cert/run.go +++ b/dgraph/cmd/cert/run.go @@ -20,8 +20,9 @@ import ( "fmt" "strings" - "github.com/dgraph-io/dgraph/x" "github.com/spf13/cobra" + + "github.com/dgraph-io/dgraph/x" ) // Cert is the sub-command invoked when running "dgraph cert". diff --git a/dgraph/cmd/conv/conv.go b/dgraph/cmd/conv/conv.go index 49efe5a5ce2..20b3b14953a 100644 --- a/dgraph/cmd/conv/conv.go +++ b/dgraph/cmd/conv/conv.go @@ -27,8 +27,9 @@ import ( "path/filepath" "strings" - "github.com/dgraph-io/dgraph/x" geojson "github.com/paulmach/go.geojson" + + "github.com/dgraph-io/dgraph/x" ) // TODO: Reconsider if we need this binary. diff --git a/dgraph/cmd/conv/run.go b/dgraph/cmd/conv/run.go index 89c2f65c127..92e82ea3258 100644 --- a/dgraph/cmd/conv/run.go +++ b/dgraph/cmd/conv/run.go @@ -20,8 +20,9 @@ import ( "fmt" "os" - "github.com/dgraph-io/dgraph/x" "github.com/spf13/cobra" + + "github.com/dgraph-io/dgraph/x" ) // Conv is the sub-command invoked when running "dgraph conv". diff --git a/dgraph/cmd/debug/run.go b/dgraph/cmd/debug/run.go index afa3840bc35..cd3996dd80e 100644 --- a/dgraph/cmd/debug/run.go +++ b/dgraph/cmd/debug/run.go @@ -26,8 +26,6 @@ import ( "log" "math" "net/http" - - //nolint:gosec // profiling on debug tool considered noncritical _ "net/http/pprof" // http profiler "os" "sort" @@ -35,11 +33,11 @@ import ( "strings" "sync/atomic" - "github.com/dgraph-io/badger/v3" - bpb "github.com/dgraph-io/badger/v3/pb" - "github.com/dgraph-io/ristretto/z" "github.com/dustin/go-humanize" + "github.com/spf13/cobra" + "github.com/dgraph-io/badger/v3" + bpb "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/dgraph/codec" "github.com/dgraph-io/dgraph/ee" "github.com/dgraph-io/dgraph/posting" @@ -47,7 +45,7 @@ import ( "github.com/dgraph-io/dgraph/raftwal" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" - "github.com/spf13/cobra" + "github.com/dgraph-io/ristretto/z" ) var ( diff --git a/dgraph/cmd/debug/wal.go b/dgraph/cmd/debug/wal.go index c71f724b09c..85ef899aef9 100644 --- a/dgraph/cmd/debug/wal.go +++ b/dgraph/cmd/debug/wal.go @@ -23,12 +23,13 @@ import ( "strconv" "strings" - "github.com/dgraph-io/dgraph/protos/pb" - "github.com/dgraph-io/dgraph/raftwal" - "github.com/dgraph-io/dgraph/x" humanize "github.com/dustin/go-humanize" "go.etcd.io/etcd/raft" "go.etcd.io/etcd/raft/raftpb" + + "github.com/dgraph-io/dgraph/protos/pb" + "github.com/dgraph-io/dgraph/raftwal" + "github.com/dgraph-io/dgraph/x" ) func printEntry(es raftpb.Entry, pending map[uint64]bool, isZero bool) { diff --git a/dgraph/cmd/debuginfo/run.go b/dgraph/cmd/debuginfo/run.go index deeae5746b0..68afd1057f0 100644 --- a/dgraph/cmd/debuginfo/run.go +++ b/dgraph/cmd/debuginfo/run.go @@ -22,9 +22,10 @@ import ( "os" "path/filepath" - "github.com/dgraph-io/dgraph/x" "github.com/golang/glog" "github.com/spf13/cobra" + + "github.com/dgraph-io/dgraph/x" ) type debugInfoCmdOpts struct { diff --git a/dgraph/cmd/decrypt/decrypt.go b/dgraph/cmd/decrypt/decrypt.go index 96893767ea3..375c9dceffd 100644 --- a/dgraph/cmd/decrypt/decrypt.go +++ b/dgraph/cmd/decrypt/decrypt.go @@ -22,11 +22,12 @@ import ( "os" "strings" + "github.com/golang/glog" + "github.com/spf13/cobra" + "github.com/dgraph-io/dgraph/ee" "github.com/dgraph-io/dgraph/ee/enc" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" - "github.com/spf13/cobra" ) type options struct { diff --git a/dgraph/cmd/increment/increment.go b/dgraph/cmd/increment/increment.go index e5a89425448..c74117d29ba 100644 --- a/dgraph/cmd/increment/increment.go +++ b/dgraph/cmd/increment/increment.go @@ -26,15 +26,15 @@ import ( "sync" "time" - "github.com/dgraph-io/dgo/v210" - "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/dgraph/x" - "github.com/dgraph-io/ristretto/z" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" "go.opencensus.io/trace" + + "github.com/dgraph-io/dgo/v210" + "github.com/dgraph-io/dgo/v210/protos/api" + "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" ) // Increment is the sub-command invoked when calling "dgraph increment". diff --git a/dgraph/cmd/increment/increment_test.go b/dgraph/cmd/increment/increment_test.go index a8b87200d4e..f7313d1c906 100644 --- a/dgraph/cmd/increment/increment_test.go +++ b/dgraph/cmd/increment/increment_test.go @@ -26,12 +26,13 @@ import ( "testing" "time" - "github.com/dgraph-io/dgo/v210" - "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/dgraph/testutil" "github.com/spf13/viper" "github.com/stretchr/testify/require" "google.golang.org/grpc/metadata" + + "github.com/dgraph-io/dgo/v210" + "github.com/dgraph-io/dgo/v210/protos/api" + "github.com/dgraph-io/dgraph/testutil" ) const N = 10 diff --git a/dgraph/cmd/live/batch.go b/dgraph/cmd/live/batch.go index f2166042d45..ded1a3e9081 100644 --- a/dgraph/cmd/live/batch.go +++ b/dgraph/cmd/live/batch.go @@ -27,6 +27,8 @@ import ( "sync/atomic" "time" + "github.com/dgryski/go-farm" + "github.com/dustin/go-humanize/english" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -40,8 +42,6 @@ import ( "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/dgraph/xidmap" - "github.com/dgryski/go-farm" - "github.com/dustin/go-humanize/english" ) // batchMutationOptions sets the clients batch mode to Pending number of buffers each of Size. diff --git a/dgraph/cmd/live/load-uids/load_test.go b/dgraph/cmd/live/load-uids/load_test.go index 9b8cacd6e2a..c3a80cab8e3 100644 --- a/dgraph/cmd/live/load-uids/load_test.go +++ b/dgraph/cmd/live/load-uids/load_test.go @@ -29,11 +29,11 @@ import ( "testing" "time" - "github.com/dgraph-io/dgo/v210" - "github.com/dgraph-io/dgo/v210/protos/api" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v210" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/ee" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" diff --git a/dgraph/cmd/live/run.go b/dgraph/cmd/live/run.go index ed76f823b69..156c82d5f97 100644 --- a/dgraph/cmd/live/run.go +++ b/dgraph/cmd/live/run.go @@ -28,8 +28,6 @@ import ( "math" "math/rand" "net/http" - - //nolint:gosec // profiling on live-loader tool considered noncritical _ "net/http/pprof" // http profiler "os" "sort" @@ -37,6 +35,11 @@ import ( "strings" "time" + "github.com/dgryski/go-farm" + "github.com/golang/glog" + "github.com/pkg/errors" + "github.com/spf13/cobra" + "github.com/spf13/viper" "google.golang.org/grpc" "google.golang.org/grpc/metadata" @@ -44,9 +47,6 @@ import ( bopt "github.com/dgraph-io/badger/v3/options" "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/ristretto/z" - "github.com/dgryski/go-farm" - "github.com/dgraph-io/dgraph/chunker" "github.com/dgraph-io/dgraph/ee" "github.com/dgraph-io/dgraph/ee/enc" @@ -55,11 +55,7 @@ import ( "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/dgraph/xidmap" - - "github.com/golang/glog" - "github.com/pkg/errors" - "github.com/spf13/cobra" - "github.com/spf13/viper" + "github.com/dgraph-io/ristretto/z" ) type options struct { diff --git a/dgraph/cmd/migrate/run.go b/dgraph/cmd/migrate/run.go index 0857a3c97d9..5cc2b3a2286 100644 --- a/dgraph/cmd/migrate/run.go +++ b/dgraph/cmd/migrate/run.go @@ -23,10 +23,11 @@ import ( "os" "strings" - "github.com/dgraph-io/dgraph/x" "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" + + "github.com/dgraph-io/dgraph/x" ) var ( diff --git a/dgraph/cmd/migrate/table_info.go b/dgraph/cmd/migrate/table_info.go index 99fec721e24..e2be4ec6cca 100644 --- a/dgraph/cmd/migrate/table_info.go +++ b/dgraph/cmd/migrate/table_info.go @@ -21,8 +21,9 @@ import ( "fmt" "strings" - "github.com/dgraph-io/dgraph/x" "github.com/pkg/errors" + + "github.com/dgraph-io/dgraph/x" ) type keyType int diff --git a/dgraph/cmd/migrate/utils.go b/dgraph/cmd/migrate/utils.go index 32f29ec2de6..e0b6eb558c6 100644 --- a/dgraph/cmd/migrate/utils.go +++ b/dgraph/cmd/migrate/utils.go @@ -24,9 +24,10 @@ import ( "reflect" "strings" - "github.com/dgraph-io/dgraph/x" "github.com/go-sql-driver/mysql" "github.com/pkg/errors" + + "github.com/dgraph-io/dgraph/x" ) func getPool(host, port, user, password, db string) (*sql.DB, diff --git a/dgraph/cmd/root.go b/dgraph/cmd/root.go index f32c02c1f1b..3937fb269b0 100644 --- a/dgraph/cmd/root.go +++ b/dgraph/cmd/root.go @@ -28,6 +28,10 @@ import ( "strings" "unicode" + "github.com/pkg/errors" + "github.com/spf13/cobra" + "github.com/spf13/viper" + "github.com/dgraph-io/dgraph/dgraph/cmd/alpha" "github.com/dgraph-io/dgraph/dgraph/cmd/bulk" "github.com/dgraph-io/dgraph/dgraph/cmd/cert" @@ -42,10 +46,6 @@ import ( "github.com/dgraph-io/dgraph/dgraph/cmd/zero" "github.com/dgraph-io/dgraph/upgrade" "github.com/dgraph-io/dgraph/x" - - "github.com/pkg/errors" - "github.com/spf13/cobra" - "github.com/spf13/viper" ) // RootCmd represents the base command when called without any subcommands @@ -262,29 +262,29 @@ http://zsh.sourceforge.net/Doc/Release/Completion-System.html // respective subcommands. If JSON hierarchical config objects are not used, convertJSON doesn't // change anything and returns the config file string as it is. For example: // -// { -// "mutations": "strict", -// "badger": { -// "compression": "zstd:1", -// "goroutines": 5 -// }, -// "raft": { -// "idx": 2, -// "learner": true -// }, -// "security": { -// "whitelist": "127.0.0.1,0.0.0.0" -// } -// } +// { +// "mutations": "strict", +// "badger": { +// "compression": "zstd:1", +// "goroutines": 5 +// }, +// "raft": { +// "idx": 2, +// "learner": true +// }, +// "security": { +// "whitelist": "127.0.0.1,0.0.0.0" +// } +// } // // Is converted into: // -// { -// "mutations": "strict", -// "badger": "compression=zstd:1; goroutines=5;", -// "raft": "idx=2; learner=true;", -// "security": "whitelist=127.0.0.1,0.0.0.0;" -// } +// { +// "mutations": "strict", +// "badger": "compression=zstd:1; goroutines=5;", +// "raft": "idx=2; learner=true;", +// "security": "whitelist=127.0.0.1,0.0.0.0;" +// } // // Viper then uses the "converted" JSON to set the z.SuperFlag strings in subcommand option structs. func convertJSON(old string) io.Reader { @@ -325,22 +325,22 @@ func convertJSON(old string) io.Reader { // subcommands. If YAML hierarchical notation is not used, convertYAML doesn't change anything and // returns the config file string as it is. For example: // -// mutations: strict -// badger: -// compression: zstd:1 -// goroutines: 5 -// raft: -// idx: 2 -// learner: true -// security: -// whitelist: "127.0.0.1,0.0.0.0" +// mutations: strict +// badger: +// compression: zstd:1 +// goroutines: 5 +// raft: +// idx: 2 +// learner: true +// security: +// whitelist: "127.0.0.1,0.0.0.0" // // Is converted into: // -// mutations: strict -// badger: "compression=zstd:1; goroutines=5;" -// raft: "idx=2; learner=true;" -// security: "whitelist=127.0.0.1,0.0.0.0;" +// mutations: strict +// badger: "compression=zstd:1; goroutines=5;" +// raft: "idx=2; learner=true;" +// security: "whitelist=127.0.0.1,0.0.0.0;" // // Viper then uses the "converted" YAML to set the z.SuperFlag strings in subcommand option structs. func convertYAML(old string) io.Reader { diff --git a/dgraph/cmd/version/version_test.go b/dgraph/cmd/version/version_test.go index 246d73db762..91ccd9bdcab 100644 --- a/dgraph/cmd/version/version_test.go +++ b/dgraph/cmd/version/version_test.go @@ -6,8 +6,9 @@ import ( "path/filepath" "testing" - "github.com/dgraph-io/dgraph/testutil" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/testutil" ) // Test `dgraph version` with an empty config file. diff --git a/dgraph/cmd/zero/assign.go b/dgraph/cmd/zero/assign.go index e2085754169..88b24bac63d 100644 --- a/dgraph/cmd/zero/assign.go +++ b/dgraph/cmd/zero/assign.go @@ -21,13 +21,13 @@ import ( "math/rand" "time" + "github.com/golang/glog" + "github.com/pkg/errors" otrace "go.opencensus.io/trace" "google.golang.org/grpc/metadata" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" - "github.com/pkg/errors" ) var emptyAssignedIds pb.AssignedIds diff --git a/dgraph/cmd/zero/http.go b/dgraph/cmd/zero/http.go index c43f5644ee5..185e8b7cdef 100644 --- a/dgraph/cmd/zero/http.go +++ b/dgraph/cmd/zero/http.go @@ -24,10 +24,11 @@ import ( "strings" "time" - "github.com/dgraph-io/dgraph/protos/pb" - "github.com/dgraph-io/dgraph/x" "github.com/gogo/protobuf/jsonpb" "github.com/golang/glog" + + "github.com/dgraph-io/dgraph/protos/pb" + "github.com/dgraph-io/dgraph/x" ) // intFromQueryParam checks for name as a query param, converts it to uint64 and returns it. diff --git a/dgraph/cmd/zero/license.go b/dgraph/cmd/zero/license.go index 9d20693d7f9..73565c77279 100644 --- a/dgraph/cmd/zero/license.go +++ b/dgraph/cmd/zero/license.go @@ -1,3 +1,4 @@ +//go:build oss // +build oss /* diff --git a/dgraph/cmd/zero/license_ee.go b/dgraph/cmd/zero/license_ee.go index d890866d224..e6b2c15a9ba 100644 --- a/dgraph/cmd/zero/license_ee.go +++ b/dgraph/cmd/zero/license_ee.go @@ -1,3 +1,4 @@ +//go:build !oss // +build !oss /* @@ -19,14 +20,14 @@ import ( "net/http" "time" - "github.com/dgraph-io/dgraph/ee/audit" + humanize "github.com/dustin/go-humanize" + "github.com/gogo/protobuf/proto" + "github.com/golang/glog" + "github.com/dgraph-io/dgraph/ee/audit" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - humanize "github.com/dustin/go-humanize" - "github.com/gogo/protobuf/proto" - "github.com/golang/glog" ) // proposeTrialLicense proposes an enterprise license valid for 30 days. diff --git a/dgraph/cmd/zero/oracle.go b/dgraph/cmd/zero/oracle.go index 43f633e3150..6111b8ec7b1 100644 --- a/dgraph/cmd/zero/oracle.go +++ b/dgraph/cmd/zero/oracle.go @@ -23,15 +23,15 @@ import ( "strings" "time" - "github.com/dgraph-io/ristretto/z" + "github.com/golang/glog" + "github.com/pkg/errors" + otrace "go.opencensus.io/trace" "github.com/dgraph-io/badger/v3/y" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" - "github.com/pkg/errors" - otrace "go.opencensus.io/trace" + "github.com/dgraph-io/ristretto/z" ) type syncMark struct { diff --git a/dgraph/cmd/zero/raft.go b/dgraph/cmd/zero/raft.go index c5ab98aed5a..d03032f2bda 100644 --- a/dgraph/cmd/zero/raft.go +++ b/dgraph/cmd/zero/raft.go @@ -27,11 +27,6 @@ import ( "sync" "time" - "github.com/dgraph-io/dgraph/conn" - "github.com/dgraph-io/dgraph/ee/audit" - "github.com/dgraph-io/dgraph/protos/pb" - "github.com/dgraph-io/dgraph/x" - "github.com/dgraph-io/ristretto/z" farm "github.com/dgryski/go-farm" "github.com/golang/glog" "github.com/google/uuid" @@ -41,6 +36,12 @@ import ( ostats "go.opencensus.io/stats" "go.opencensus.io/tag" otrace "go.opencensus.io/trace" + + "github.com/dgraph-io/dgraph/conn" + "github.com/dgraph-io/dgraph/ee/audit" + "github.com/dgraph-io/dgraph/protos/pb" + "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" ) const ( diff --git a/dgraph/cmd/zero/run.go b/dgraph/cmd/zero/run.go index cee3bf33c1d..41ec2ba65ab 100644 --- a/dgraph/cmd/zero/run.go +++ b/dgraph/cmd/zero/run.go @@ -29,9 +29,8 @@ import ( "syscall" "time" - "github.com/dgraph-io/dgraph/ee/audit" - "github.com/dgraph-io/dgraph/worker" - + "github.com/golang/glog" + "github.com/spf13/cobra" "go.opencensus.io/plugin/ocgrpc" otrace "go.opencensus.io/trace" "go.opencensus.io/zpages" @@ -40,13 +39,13 @@ import ( "google.golang.org/grpc/credentials" "github.com/dgraph-io/dgraph/conn" + "github.com/dgraph-io/dgraph/ee/audit" "github.com/dgraph-io/dgraph/ee/enc" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/raftwal" + "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - "github.com/golang/glog" - "github.com/spf13/cobra" ) type options struct { diff --git a/dgraph/cmd/zero/tablet.go b/dgraph/cmd/zero/tablet.go index 9c9e1d185e5..205de6e0ecb 100644 --- a/dgraph/cmd/zero/tablet.go +++ b/dgraph/cmd/zero/tablet.go @@ -22,12 +22,13 @@ import ( "sort" "time" - "github.com/dgraph-io/dgraph/protos/pb" - "github.com/dgraph-io/dgraph/x" humanize "github.com/dustin/go-humanize" "github.com/golang/glog" "github.com/pkg/errors" otrace "go.opencensus.io/trace" + + "github.com/dgraph-io/dgraph/protos/pb" + "github.com/dgraph-io/dgraph/x" ) const ( @@ -58,7 +59,7 @@ This would trigger G1 to get latest state. Wait for it. */ -// TODO: Have a event log for everything. +// TODO: Have a event log for everything. func (s *Server) rebalanceTablets() { ticker := time.NewTicker(opts.rebalanceInterval) for range ticker.C { diff --git a/dgraph/cmd/zero/zero.go b/dgraph/cmd/zero/zero.go index 72eddfd7df3..839963714c1 100644 --- a/dgraph/cmd/zero/zero.go +++ b/dgraph/cmd/zero/zero.go @@ -25,6 +25,9 @@ import ( "sync" "time" + "github.com/gogo/protobuf/proto" + "github.com/golang/glog" + "github.com/pkg/errors" otrace "go.opencensus.io/trace" "github.com/dgraph-io/dgo/v210/protos/api" @@ -33,9 +36,6 @@ import ( "github.com/dgraph-io/dgraph/telemetry" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - "github.com/gogo/protobuf/proto" - "github.com/golang/glog" - "github.com/pkg/errors" ) var ( diff --git a/dgraph/cmd/zero/zero_test.go b/dgraph/cmd/zero/zero_test.go index 71887862f16..95fc4650ef0 100644 --- a/dgraph/cmd/zero/zero_test.go +++ b/dgraph/cmd/zero/zero_test.go @@ -21,10 +21,11 @@ import ( "math" "testing" - "github.com/dgraph-io/dgraph/protos/pb" - "github.com/dgraph-io/dgraph/testutil" "github.com/stretchr/testify/require" "google.golang.org/grpc" + + "github.com/dgraph-io/dgraph/protos/pb" + "github.com/dgraph-io/dgraph/testutil" ) func TestRemoveNode(t *testing.T) { diff --git a/dgraph/main.go b/dgraph/main.go index 59fb3540e1f..6a468725a6e 100644 --- a/dgraph/main.go +++ b/dgraph/main.go @@ -21,10 +21,11 @@ import ( "runtime" "time" - "github.com/dgraph-io/dgraph/dgraph/cmd" - "github.com/dgraph-io/ristretto/z" "github.com/dustin/go-humanize" "github.com/golang/glog" + + "github.com/dgraph-io/dgraph/dgraph/cmd" + "github.com/dgraph-io/ristretto/z" ) func main() { diff --git a/dql/bench_test.go b/dql/bench_test.go index 85e5ecd967f..d2d2cf788c5 100644 --- a/dql/bench_test.go +++ b/dql/bench_test.go @@ -19,8 +19,9 @@ package dql import ( "testing" - "github.com/dgraph-io/dgraph/schema" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/schema" ) var sc = `type.object.name.en: string @index . diff --git a/dql/math.go b/dql/math.go index d69b60c2589..77083873126 100644 --- a/dql/math.go +++ b/dql/math.go @@ -21,10 +21,11 @@ import ( "strconv" "strings" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/lex" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" ) type mathTreeStack struct{ a []*MathTree } diff --git a/dql/mutation.go b/dql/mutation.go index 3ede3923c7c..48f47b857fd 100644 --- a/dql/mutation.go +++ b/dql/mutation.go @@ -19,11 +19,12 @@ package dql import ( "strconv" + "github.com/pkg/errors" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" ) var ( diff --git a/dql/parser.go b/dql/parser.go index bb9a0fd6e7f..8e8646ccb17 100644 --- a/dql/parser.go +++ b/dql/parser.go @@ -23,11 +23,12 @@ import ( "strconv" "strings" + "github.com/golang/glog" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/lex" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" - "github.com/pkg/errors" ) const ( diff --git a/dql/parser_test.go b/dql/parser_test.go index 76699d2e0ad..861607950c7 100644 --- a/dql/parser_test.go +++ b/dql/parser_test.go @@ -22,11 +22,12 @@ import ( "runtime/debug" "testing" + "github.com/pkg/errors" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/chunker" "github.com/dgraph-io/dgraph/lex" - "github.com/pkg/errors" - "github.com/stretchr/testify/require" ) func childAttrs(g *GraphQuery) []string { diff --git a/edgraph/access.go b/edgraph/access.go index 3047e2285b6..49012ff0b99 100644 --- a/edgraph/access.go +++ b/edgraph/access.go @@ -1,3 +1,4 @@ +//go:build oss // +build oss /* @@ -21,12 +22,13 @@ package edgraph import ( "context" + "github.com/golang/glog" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/dql" "github.com/dgraph-io/dgraph/query" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - "github.com/golang/glog" ) // Login handles login requests from clients. This version rejects all requests diff --git a/edgraph/access_ee.go b/edgraph/access_ee.go index 32a1dab419d..1bba2d64041 100644 --- a/edgraph/access_ee.go +++ b/edgraph/access_ee.go @@ -21,25 +21,23 @@ import ( "strings" "time" - "github.com/dgraph-io/dgraph/protos/pb" - "github.com/dgraph-io/ristretto/z" - - "github.com/dgraph-io/dgraph/query" - + jwt "github.com/dgrijalva/jwt-go" + "github.com/golang/glog" "github.com/pkg/errors" + otrace "go.opencensus.io/trace" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" bpb "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/dql" "github.com/dgraph-io/dgraph/ee/acl" + "github.com/dgraph-io/dgraph/protos/pb" + "github.com/dgraph-io/dgraph/query" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" - jwt "github.com/dgrijalva/jwt-go" - "github.com/golang/glog" - otrace "go.opencensus.io/trace" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" + "github.com/dgraph-io/ristretto/z" ) type predsAndvars struct { @@ -195,7 +193,7 @@ func validateToken(jwtStr string) (*userData, error) { return nil, errors.Errorf("userid in claims is not a string:%v", userId) } - /* + /* * Since, JSON numbers follow JavaScript's double-precision floating-point * format . . . * -- references: https://restfulapi.net/json-data-types/ diff --git a/edgraph/access_ee_test.go b/edgraph/access_ee_test.go index 0a74f6eee18..970d7b49b6a 100644 --- a/edgraph/access_ee_test.go +++ b/edgraph/access_ee_test.go @@ -1,5 +1,5 @@ //go:build !oss -//+build !oss +// +build !oss /* * Copyright 2022 Dgraph Labs, Inc. All rights reserved. @@ -17,17 +17,17 @@ import ( "testing" "time" + jwt "github.com/dgrijalva/jwt-go" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgraph/ee/acl" "github.com/dgraph-io/dgraph/worker" - - "github.com/stretchr/testify/require" - jwt "github.com/dgrijalva/jwt-go" ) func generateJWT(namespace uint64, userId string, groupIds []string, expiry int64) string { claims := jwt.MapClaims{"namespace": namespace, "userid": userId, "exp": expiry} if groupIds != nil { - claims["groups"] = groupIds + claims["groups"] = groupIds } token := jwt.NewWithClaims(jwt.SigningMethodHS256, &claims) @@ -100,11 +100,11 @@ func TestGetAccessJwt(t *testing.T) { for _, userdata := range userDataList { jwtstr, _ := getAccessJwt(userdata.userId, grpLst, userdata.namespace) - ud, err := validateToken (jwtstr) + ud, err := validateToken(jwtstr) require.Nil(t, err) if ud.namespace != userdata.namespace || ud.userId != userdata.userId || !sliceCompare(ud.groupIds, g) { t.Errorf("Actual output {%v %v %v} is not equal to the output %v generated from"+ - " getAccessJwt() token", userdata.namespace, userdata.userId, grpLst, ud) + " getAccessJwt() token", userdata.namespace, userdata.userId, grpLst, ud) } } } @@ -118,11 +118,11 @@ func TestGetRefreshJwt(t *testing.T) { for _, userdata := range userDataList { jwtstr, _ := getRefreshJwt(userdata.userId, userdata.namespace) - ud, err := validateToken (jwtstr) + ud, err := validateToken(jwtstr) require.Nil(t, err) if ud.namespace != userdata.namespace || ud.userId != userdata.userId { t.Errorf("Actual output {%v %v} is not equal to the output {%v %v} generated from"+ - "getRefreshJwt() token", userdata.namespace, userdata.userId, ud.namespace, ud.userId) + "getRefreshJwt() token", userdata.namespace, userdata.userId, ud.namespace, ud.userId) } } } diff --git a/edgraph/config_mem.go b/edgraph/config_mem.go index dcc6371194d..4552e77d357 100644 --- a/edgraph/config_mem.go +++ b/edgraph/config_mem.go @@ -1,3 +1,4 @@ +//go:build (linux || darwin) && cgo // +build linux darwin // +build cgo diff --git a/edgraph/graphql.go b/edgraph/graphql.go index a0ca2a9dabd..08a018b5289 100644 --- a/edgraph/graphql.go +++ b/edgraph/graphql.go @@ -23,24 +23,25 @@ import ( "encoding/json" "fmt" + "github.com/golang/glog" + "github.com/pkg/errors" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" - "github.com/pkg/errors" ) // ProcessPersistedQuery stores and retrieves persisted queries by following waterfall logic: -// 1. If sha256Hash is not provided process queries without persisting -// 2. If sha256Hash is provided try retrieving persisted queries -// 2a. Persisted Query not found -// i) If query is not provided then throw "PersistedQueryNotFound" -// ii) If query is provided then store query in dgraph only if sha256 of the query is correct -// otherwise throw "provided sha does not match query" -// 2b. Persisted Query found -// i) If query is not provided then update gqlRes with the found query and proceed -// ii) If query is provided then match query retrieved, if identical do nothing else -// throw "query does not match persisted query" +// 1. If sha256Hash is not provided process queries without persisting +// 2. If sha256Hash is provided try retrieving persisted queries +// 2a. Persisted Query not found +// i) If query is not provided then throw "PersistedQueryNotFound" +// ii) If query is provided then store query in dgraph only if sha256 of the query is correct +// otherwise throw "provided sha does not match query" +// 2b. Persisted Query found +// i) If query is not provided then update gqlRes with the found query and proceed +// ii) If query is provided then match query retrieved, if identical do nothing else +// throw "query does not match persisted query" func ProcessPersistedQuery(ctx context.Context, gqlReq *schema.Request) error { query := gqlReq.Query sha256Hash := gqlReq.Extensions.PersistedQuery.Sha256Hash diff --git a/edgraph/multi_tenancy.go b/edgraph/multi_tenancy.go index 06ae2860742..2ef6ddf6be9 100644 --- a/edgraph/multi_tenancy.go +++ b/edgraph/multi_tenancy.go @@ -1,3 +1,4 @@ +//go:build oss // +build oss /* diff --git a/edgraph/multi_tenancy_ee.go b/edgraph/multi_tenancy_ee.go index 5b692de1425..7be9a0a58f6 100644 --- a/edgraph/multi_tenancy_ee.go +++ b/edgraph/multi_tenancy_ee.go @@ -1,3 +1,4 @@ +//go:build !oss // +build !oss /* @@ -18,14 +19,15 @@ import ( "fmt" "time" + "github.com/golang/glog" + "github.com/pkg/errors" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/query" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" - "github.com/pkg/errors" ) type ResetPasswordInput struct { diff --git a/edgraph/server_test.go b/edgraph/server_test.go index f622ffbcc93..0b1f3f3c90b 100644 --- a/edgraph/server_test.go +++ b/edgraph/server_test.go @@ -18,16 +18,17 @@ package edgraph import ( "context" - "github.com/dgraph-io/dgraph/schema" - "google.golang.org/grpc/metadata" "io/ioutil" "testing" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/metadata" + "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/chunker" + "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/x" - "github.com/stretchr/testify/require" ) func makeNquad(sub, pred string, val *api.Value) *api.NQuad { diff --git a/ee/acl/acl.go b/ee/acl/acl.go index f47f4be434e..96421860ff7 100644 --- a/ee/acl/acl.go +++ b/ee/acl/acl.go @@ -1,3 +1,4 @@ +//go:build !oss // +build !oss /* @@ -19,12 +20,13 @@ import ( "strings" "time" - "github.com/dgraph-io/dgo/v210" - "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/dgraph/x" "github.com/golang/glog" "github.com/pkg/errors" "github.com/spf13/viper" + + "github.com/dgraph-io/dgo/v210" + "github.com/dgraph-io/dgo/v210/protos/api" + "github.com/dgraph-io/dgraph/x" ) func getUserAndGroup(conf *viper.Viper) (userId string, groupId string, err error) { diff --git a/ee/acl/acl_curl_test.go b/ee/acl/acl_curl_test.go index 1ba3125f968..02a48bd0f2c 100644 --- a/ee/acl/acl_curl_test.go +++ b/ee/acl/acl_curl_test.go @@ -1,3 +1,4 @@ +//go:build !oss // +build !oss /* @@ -17,10 +18,11 @@ import ( "testing" "time" - "github.com/dgraph-io/dgraph/testutil" - "github.com/dgraph-io/dgraph/x" "github.com/golang/glog" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/testutil" + "github.com/dgraph-io/dgraph/x" ) var adminEndpoint string diff --git a/ee/acl/acl_test.go b/ee/acl/acl_test.go index bb408b4035c..7a9f061e744 100644 --- a/ee/acl/acl_test.go +++ b/ee/acl/acl_test.go @@ -24,13 +24,13 @@ import ( "testing" "time" + "github.com/golang/glog" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" - - "github.com/golang/glog" - "github.com/stretchr/testify/require" ) var ( diff --git a/ee/acl/run.go b/ee/acl/run.go index 705962a4eea..0d0f7a93fec 100644 --- a/ee/acl/run.go +++ b/ee/acl/run.go @@ -1,3 +1,4 @@ +//go:build oss // +build oss /* @@ -19,8 +20,9 @@ package acl import ( - "github.com/dgraph-io/dgraph/x" "github.com/spf13/cobra" + + "github.com/dgraph-io/dgraph/x" ) var CmdAcl x.SubCommand diff --git a/ee/acl/run_ee.go b/ee/acl/run_ee.go index aa8fa19d3dc..410b7569806 100644 --- a/ee/acl/run_ee.go +++ b/ee/acl/run_ee.go @@ -1,3 +1,4 @@ +//go:build !oss // +build !oss /* @@ -16,10 +17,11 @@ import ( "fmt" "os" - "github.com/dgraph-io/dgraph/x" "github.com/golang/glog" "github.com/spf13/cobra" "github.com/spf13/viper" + + "github.com/dgraph-io/dgraph/x" ) var ( diff --git a/ee/acl/utils.go b/ee/acl/utils.go index 9bcaa9a697d..70a1c812ead 100644 --- a/ee/acl/utils.go +++ b/ee/acl/utils.go @@ -1,3 +1,4 @@ +//go:build !oss // +build !oss /* @@ -15,13 +16,14 @@ package acl import ( "encoding/json" + "github.com/golang/glog" + "github.com/pkg/errors" + "github.com/spf13/viper" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - "github.com/golang/glog" - "github.com/pkg/errors" - "github.com/spf13/viper" ) // GetGroupIDs returns a slice containing the group ids of all the given groups. diff --git a/ee/audit/audit.go b/ee/audit/audit.go index 6fdf6796f76..505628d1a9c 100644 --- a/ee/audit/audit.go +++ b/ee/audit/audit.go @@ -1,3 +1,4 @@ +//go:build oss // +build oss /* diff --git a/ee/audit/audit_ee.go b/ee/audit/audit_ee.go index 837d75d7c54..a40f1b22c5b 100644 --- a/ee/audit/audit_ee.go +++ b/ee/audit/audit_ee.go @@ -1,3 +1,4 @@ +//go:build !oss // +build !oss /* @@ -19,11 +20,11 @@ import ( "sync/atomic" "time" - "github.com/dgraph-io/ristretto/z" + "github.com/golang/glog" "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" + "github.com/dgraph-io/ristretto/z" ) const ( diff --git a/ee/audit/interceptor.go b/ee/audit/interceptor.go index 1a8e69f5d93..025be8cb26b 100644 --- a/ee/audit/interceptor.go +++ b/ee/audit/interceptor.go @@ -1,3 +1,4 @@ +//go:build oss // +build oss /* diff --git a/ee/audit/interceptor_ee.go b/ee/audit/interceptor_ee.go index e9de9a1b777..fdfa58e6bf0 100644 --- a/ee/audit/interceptor_ee.go +++ b/ee/audit/interceptor_ee.go @@ -1,3 +1,4 @@ +//go:build !oss // +build !oss /* @@ -25,18 +26,17 @@ import ( "strings" "sync/atomic" - "github.com/dgraph-io/dgraph/graphql/schema" - "github.com/dgraph-io/gqlparser/v2/ast" - "github.com/dgraph-io/gqlparser/v2/parser" "github.com/golang/glog" - - "github.com/dgraph-io/dgraph/x" + "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" "google.golang.org/grpc/peer" "google.golang.org/grpc/status" - "google.golang.org/grpc" + "github.com/dgraph-io/dgraph/graphql/schema" + "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/gqlparser/v2/ast" + "github.com/dgraph-io/gqlparser/v2/parser" ) const ( diff --git a/ee/audit/run.go b/ee/audit/run.go index 4c253f606b1..3d19a301b94 100644 --- a/ee/audit/run.go +++ b/ee/audit/run.go @@ -1,3 +1,4 @@ +//go:build oss // +build oss /* @@ -19,8 +20,9 @@ package audit import ( - "github.com/dgraph-io/dgraph/x" "github.com/spf13/cobra" + + "github.com/dgraph-io/dgraph/x" ) var CmdAudit x.SubCommand diff --git a/ee/audit/run_ee.go b/ee/audit/run_ee.go index 4141d5c7510..97cf2d63327 100644 --- a/ee/audit/run_ee.go +++ b/ee/audit/run_ee.go @@ -1,3 +1,4 @@ +//go:build !oss // +build !oss /* @@ -21,10 +22,11 @@ import ( "io/ioutil" "os" - "github.com/dgraph-io/dgraph/x" "github.com/golang/glog" "github.com/spf13/cobra" "github.com/spf13/viper" + + "github.com/dgraph-io/dgraph/x" ) var CmdAudit x.SubCommand diff --git a/ee/backup/run.go b/ee/backup/run.go index 650e31497b0..08ebc89672d 100644 --- a/ee/backup/run.go +++ b/ee/backup/run.go @@ -23,6 +23,12 @@ import ( "path/filepath" "time" + "github.com/golang/glog" + "github.com/pkg/errors" + "github.com/spf13/cobra" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials" + bpb "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/dgraph/ee" "github.com/dgraph-io/dgraph/posting" @@ -30,12 +36,6 @@ import ( "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - - "github.com/golang/glog" - "github.com/pkg/errors" - "github.com/spf13/cobra" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials" ) // Restore is the sub-command used to restore a backup. diff --git a/ee/enc/util.go b/ee/enc/util.go index 2d93d1409e0..f62ce17636e 100644 --- a/ee/enc/util.go +++ b/ee/enc/util.go @@ -1,3 +1,4 @@ +//go:build oss // +build oss /* diff --git a/ee/enc/util_ee.go b/ee/enc/util_ee.go index 77fe5c52a36..b994d184c73 100644 --- a/ee/enc/util_ee.go +++ b/ee/enc/util_ee.go @@ -18,9 +18,10 @@ import ( "crypto/cipher" "io" + "github.com/pkg/errors" + "github.com/dgraph-io/badger/v3/y" "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" ) // EeBuild indicates if this is a Enterprise build. diff --git a/ee/flags.go b/ee/flags.go index 6c3c93c3e95..db2b945a126 100644 --- a/ee/flags.go +++ b/ee/flags.go @@ -21,9 +21,10 @@ import ( "strings" "time" + "github.com/spf13/pflag" + "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - "github.com/spf13/pflag" ) // Keys holds the configuration for ACL and encryption. diff --git a/ee/keys_ee.go b/ee/keys_ee.go index d9e2a5c304f..b215bf8399a 100644 --- a/ee/keys_ee.go +++ b/ee/keys_ee.go @@ -17,8 +17,9 @@ import ( "fmt" "io/ioutil" - "github.com/dgraph-io/ristretto/z" "github.com/spf13/viper" + + "github.com/dgraph-io/ristretto/z" ) // GetKeys returns the ACL and encryption keys as configured by the user diff --git a/ee/vault/vault.go b/ee/vault/vault.go index 64ad7a212a9..6c25b45ce51 100644 --- a/ee/vault/vault.go +++ b/ee/vault/vault.go @@ -20,10 +20,10 @@ package vault import ( - "github.com/dgraph-io/dgraph/ee" - "github.com/golang/glog" "github.com/spf13/viper" + + "github.com/dgraph-io/dgraph/ee" ) func GetKeys(config *viper.Viper) (*ee.Keys, error) { diff --git a/ee/vault_ee.go b/ee/vault_ee.go index 0b05f31ef65..6bf7dd78053 100644 --- a/ee/vault_ee.go +++ b/ee/vault_ee.go @@ -19,12 +19,12 @@ import ( "io/ioutil" "reflect" - "github.com/dgraph-io/dgraph/x" - - "github.com/dgraph-io/ristretto/z" "github.com/golang/glog" "github.com/hashicorp/vault/api" "github.com/spf13/viper" + + "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" ) func vaultGetKeys(config *viper.Viper) (aclKey, encKey x.Sensitive) { diff --git a/filestore/remote_files.go b/filestore/remote_files.go index fa1f3e4097f..0ac8fead8da 100644 --- a/filestore/remote_files.go +++ b/filestore/remote_files.go @@ -22,9 +22,10 @@ import ( "net/url" "strings" + "github.com/minio/minio-go/v6" + "github.com/dgraph-io/dgraph/chunker" "github.com/dgraph-io/dgraph/x" - "github.com/minio/minio-go/v6" ) type remoteFiles struct { diff --git a/graphql/admin/backup.go b/graphql/admin/backup.go index d97e6d1d31f..bd5613617f8 100644 --- a/graphql/admin/backup.go +++ b/graphql/admin/backup.go @@ -21,11 +21,12 @@ import ( "encoding/json" "fmt" + "github.com/golang/glog" + "github.com/dgraph-io/dgraph/graphql/resolve" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/worker" - "github.com/golang/glog" ) type backupInput struct { diff --git a/graphql/admin/config.go b/graphql/admin/config.go index 0473ad86f41..c4bb8895ba2 100644 --- a/graphql/admin/config.go +++ b/graphql/admin/config.go @@ -21,10 +21,11 @@ import ( "encoding/json" "strconv" + "github.com/golang/glog" + "github.com/dgraph-io/dgraph/graphql/resolve" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/worker" - "github.com/golang/glog" ) type configInput struct { diff --git a/graphql/admin/draining.go b/graphql/admin/draining.go index 3b7231e433a..f2e7b683099 100644 --- a/graphql/admin/draining.go +++ b/graphql/admin/draining.go @@ -20,10 +20,11 @@ import ( "context" "fmt" + "github.com/golang/glog" + "github.com/dgraph-io/dgraph/graphql/resolve" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" ) func resolveDraining(ctx context.Context, m schema.Mutation) (*resolve.Resolved, bool) { diff --git a/graphql/admin/endpoints.go b/graphql/admin/endpoints.go index bd596eb012e..6f7b177a7c9 100644 --- a/graphql/admin/endpoints.go +++ b/graphql/admin/endpoints.go @@ -1,3 +1,4 @@ +//go:build oss // +build oss /* diff --git a/graphql/admin/endpoints_ee.go b/graphql/admin/endpoints_ee.go index 2cfd84757eb..fc67953e98a 100644 --- a/graphql/admin/endpoints_ee.go +++ b/graphql/admin/endpoints_ee.go @@ -1,3 +1,4 @@ +//go:build !oss // +build !oss /* diff --git a/graphql/admin/export.go b/graphql/admin/export.go index 6b3e9bf81a2..8f7e7ee5cbd 100644 --- a/graphql/admin/export.go +++ b/graphql/admin/export.go @@ -21,13 +21,14 @@ import ( "encoding/json" "math" + "github.com/golang/glog" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/graphql/resolve" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" - "github.com/pkg/errors" ) const notSet = math.MaxInt64 diff --git a/graphql/admin/health.go b/graphql/admin/health.go index 86d484c4cee..c0bb5332d27 100644 --- a/graphql/admin/health.go +++ b/graphql/admin/health.go @@ -19,12 +19,13 @@ package admin import ( "context" + "github.com/golang/glog" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/edgraph" "github.com/dgraph-io/dgraph/graphql/resolve" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" - "github.com/pkg/errors" ) func resolveHealth(ctx context.Context, q schema.Query) *resolve.Resolved { diff --git a/graphql/admin/http.go b/graphql/admin/http.go index 56fdf51e0cc..6cd2c7b2e4b 100644 --- a/graphql/admin/http.go +++ b/graphql/admin/http.go @@ -28,6 +28,10 @@ import ( "strings" "sync" + "github.com/golang/glog" + "github.com/pkg/errors" + "go.opencensus.io/trace" + "github.com/dgraph-io/dgraph/edgraph" "github.com/dgraph-io/dgraph/graphql/api" "github.com/dgraph-io/dgraph/graphql/resolve" @@ -35,9 +39,6 @@ import ( "github.com/dgraph-io/dgraph/graphql/subscription" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/graphql-transport-ws/graphqlws" - "github.com/golang/glog" - "github.com/pkg/errors" - "go.opencensus.io/trace" ) type Headerkey string diff --git a/graphql/admin/list_backups.go b/graphql/admin/list_backups.go index e896bf1e148..0d10b988c30 100644 --- a/graphql/admin/list_backups.go +++ b/graphql/admin/list_backups.go @@ -20,11 +20,12 @@ import ( "context" "encoding/json" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/graphql/resolve" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" ) type lsBackupInput struct { diff --git a/graphql/admin/login.go b/graphql/admin/login.go index 4de1b9ae863..3792622e7b1 100644 --- a/graphql/admin/login.go +++ b/graphql/admin/login.go @@ -20,11 +20,12 @@ import ( "context" "encoding/json" + "github.com/golang/glog" + dgoapi "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/edgraph" "github.com/dgraph-io/dgraph/graphql/resolve" "github.com/dgraph-io/dgraph/graphql/schema" - "github.com/golang/glog" ) type loginInput struct { diff --git a/graphql/admin/moveTablet.go b/graphql/admin/moveTablet.go index 7c74c4a0b91..1bbc264f197 100644 --- a/graphql/admin/moveTablet.go +++ b/graphql/admin/moveTablet.go @@ -19,14 +19,13 @@ package admin import ( "context" - "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" "github.com/dgraph-io/dgraph/graphql/resolve" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/worker" + "github.com/dgraph-io/dgraph/x" ) type moveTabletInput struct { diff --git a/graphql/admin/reset_password.go b/graphql/admin/reset_password.go index 16f549bd964..969d9ecc15d 100644 --- a/graphql/admin/reset_password.go +++ b/graphql/admin/reset_password.go @@ -21,10 +21,11 @@ import ( "encoding/json" "strconv" + "github.com/golang/glog" + "github.com/dgraph-io/dgraph/edgraph" "github.com/dgraph-io/dgraph/graphql/resolve" "github.com/dgraph-io/dgraph/graphql/schema" - "github.com/golang/glog" ) func resolveResetPassword(ctx context.Context, m schema.Mutation) (*resolve.Resolved, bool) { diff --git a/graphql/admin/restore.go b/graphql/admin/restore.go index 8ad079b6dab..f2f91f3eeaf 100644 --- a/graphql/admin/restore.go +++ b/graphql/admin/restore.go @@ -21,13 +21,13 @@ import ( "encoding/json" "sync" - "github.com/dgraph-io/dgraph/edgraph" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/edgraph" "github.com/dgraph-io/dgraph/graphql/resolve" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/worker" - "github.com/pkg/errors" ) type restoreInput struct { diff --git a/graphql/admin/schema.go b/graphql/admin/schema.go index 29a1e7360f8..9558aa806c9 100644 --- a/graphql/admin/schema.go +++ b/graphql/admin/schema.go @@ -19,14 +19,15 @@ package admin import ( "context" "encoding/json" - "github.com/dgraph-io/dgraph/worker" + + "github.com/golang/glog" "github.com/dgraph-io/dgraph/edgraph" "github.com/dgraph-io/dgraph/graphql/resolve" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/query" + "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" ) type getSchemaResolver struct { diff --git a/graphql/admin/shutdown.go b/graphql/admin/shutdown.go index d78398a019f..693064327d8 100644 --- a/graphql/admin/shutdown.go +++ b/graphql/admin/shutdown.go @@ -19,10 +19,11 @@ package admin import ( "context" + "github.com/golang/glog" + "github.com/dgraph-io/dgraph/graphql/resolve" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" ) func resolveShutdown(ctx context.Context, m schema.Mutation) (*resolve.Resolved, bool) { diff --git a/graphql/admin/state.go b/graphql/admin/state.go index e16960a7581..1b851ba1b27 100644 --- a/graphql/admin/state.go +++ b/graphql/admin/state.go @@ -5,13 +5,14 @@ import ( "context" "encoding/json" + "github.com/gogo/protobuf/jsonpb" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/edgraph" "github.com/dgraph-io/dgraph/graphql/resolve" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" - "github.com/gogo/protobuf/jsonpb" - "github.com/pkg/errors" ) type membershipState struct { diff --git a/graphql/admin/task.go b/graphql/admin/task.go index 237d813ab38..1777c01b485 100644 --- a/graphql/admin/task.go +++ b/graphql/admin/task.go @@ -23,11 +23,12 @@ import ( "strconv" "time" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/graphql/resolve" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/worker" - "github.com/pkg/errors" ) type taskInput struct { diff --git a/graphql/authorization/auth.go b/graphql/authorization/auth.go index 0d272f3b523..bfa33ca583f 100644 --- a/graphql/authorization/auth.go +++ b/graphql/authorization/auth.go @@ -29,11 +29,12 @@ import ( "strings" "time" - "github.com/dgraph-io/gqlparser/v2/gqlerror" "github.com/dgrijalva/jwt-go/v4" "github.com/pkg/errors" "google.golang.org/grpc/metadata" "gopkg.in/square/go-jose.v2" + + "github.com/dgraph-io/gqlparser/v2/gqlerror" ) type ctxKey string diff --git a/graphql/bench/auth_test.go b/graphql/bench/auth_test.go index ceafa879213..fff18304034 100644 --- a/graphql/bench/auth_test.go +++ b/graphql/bench/auth_test.go @@ -23,10 +23,11 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgraph/graphql/authorization" "github.com/dgraph-io/dgraph/graphql/e2e/common" "github.com/dgraph-io/dgraph/testutil" - "github.com/stretchr/testify/require" ) const ( diff --git a/graphql/e2e/admin_auth/poorman_auth/admin_auth_test.go b/graphql/e2e/admin_auth/poorman_auth/admin_auth_test.go index 295597b8e55..820a4451b5d 100644 --- a/graphql/e2e/admin_auth/poorman_auth/admin_auth_test.go +++ b/graphql/e2e/admin_auth/poorman_auth/admin_auth_test.go @@ -22,11 +22,10 @@ import ( "strings" "testing" - "github.com/dgraph-io/dgraph/x" - "github.com/stretchr/testify/require" "github.com/dgraph-io/dgraph/graphql/e2e/common" + "github.com/dgraph-io/dgraph/x" ) const ( diff --git a/graphql/e2e/admin_auth/poorman_auth_with_acl/admin_auth_test.go b/graphql/e2e/admin_auth/poorman_auth_with_acl/admin_auth_test.go index 74ded204c8e..fb8a0efc2c6 100644 --- a/graphql/e2e/admin_auth/poorman_auth_with_acl/admin_auth_test.go +++ b/graphql/e2e/admin_auth/poorman_auth_with_acl/admin_auth_test.go @@ -22,11 +22,10 @@ import ( "testing" "time" - "github.com/dgraph-io/dgraph/x" - "github.com/stretchr/testify/require" "github.com/dgraph-io/dgraph/graphql/e2e/common" + "github.com/dgraph-io/dgraph/x" ) const ( diff --git a/graphql/e2e/auth/add_mutation_test.go b/graphql/e2e/auth/add_mutation_test.go index 6fe8c95de81..e8f1b4523ea 100644 --- a/graphql/e2e/auth/add_mutation_test.go +++ b/graphql/e2e/auth/add_mutation_test.go @@ -20,10 +20,11 @@ import ( "encoding/json" "testing" - "github.com/dgraph-io/dgraph/graphql/e2e/common" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/graphql/e2e/common" ) func (p *Project) delete(t *testing.T, user, role string) { diff --git a/graphql/e2e/auth/auth_test.go b/graphql/e2e/auth/auth_test.go index f0e7b9c57b1..689d060ebef 100644 --- a/graphql/e2e/auth/auth_test.go +++ b/graphql/e2e/auth/auth_test.go @@ -25,16 +25,14 @@ import ( "strings" "testing" - "github.com/dgraph-io/dgraph/graphql/authorization" - "github.com/dgrijalva/jwt-go/v4" - + "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgraph/graphql/authorization" "github.com/dgraph-io/dgraph/graphql/e2e/common" "github.com/dgraph-io/dgraph/testutil" - "github.com/google/go-cmp/cmp" - "github.com/stretchr/testify/require" ) var ( diff --git a/graphql/e2e/auth/debug_off/debugoff_test.go b/graphql/e2e/auth/debug_off/debugoff_test.go index f18354c057b..fdbcf22bfd3 100644 --- a/graphql/e2e/auth/debug_off/debugoff_test.go +++ b/graphql/e2e/auth/debug_off/debugoff_test.go @@ -7,14 +7,14 @@ import ( "testing" "github.com/dgrijalva/jwt-go/v4" - - "github.com/dgraph-io/dgraph/graphql/authorization" - "github.com/dgraph-io/dgraph/graphql/e2e/common" - "github.com/dgraph-io/dgraph/testutil" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/pkg/errors" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/graphql/authorization" + "github.com/dgraph-io/dgraph/graphql/e2e/common" + "github.com/dgraph-io/dgraph/testutil" ) var ( diff --git a/graphql/e2e/auth/delete_mutation_test.go b/graphql/e2e/auth/delete_mutation_test.go index af4ee11b986..f935273540a 100644 --- a/graphql/e2e/auth/delete_mutation_test.go +++ b/graphql/e2e/auth/delete_mutation_test.go @@ -5,8 +5,9 @@ import ( "strconv" "testing" - "github.com/dgraph-io/dgraph/graphql/e2e/common" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/graphql/e2e/common" ) func (c *Column) add(t *testing.T, user, role string) { diff --git a/graphql/e2e/auth/update_mutation_test.go b/graphql/e2e/auth/update_mutation_test.go index a71e6195cbc..e3dd1099167 100644 --- a/graphql/e2e/auth/update_mutation_test.go +++ b/graphql/e2e/auth/update_mutation_test.go @@ -20,8 +20,9 @@ import ( "encoding/json" "testing" - "github.com/dgraph-io/dgraph/graphql/e2e/common" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/graphql/e2e/common" ) func getAllProjects(t *testing.T, users, roles []string) []string { diff --git a/graphql/e2e/auth_closed_by_default/auth_closed_by_default_test.go b/graphql/e2e/auth_closed_by_default/auth_closed_by_default_test.go index 849a372a461..2b226de7659 100644 --- a/graphql/e2e/auth_closed_by_default/auth_closed_by_default_test.go +++ b/graphql/e2e/auth_closed_by_default/auth_closed_by_default_test.go @@ -20,10 +20,11 @@ import ( "os" "testing" - "github.com/dgraph-io/dgraph/graphql/e2e/common" - "github.com/dgraph-io/dgraph/testutil" "github.com/dgrijalva/jwt-go/v4" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/graphql/e2e/common" + "github.com/dgraph-io/dgraph/testutil" ) type TestCase struct { diff --git a/graphql/e2e/common/admin.go b/graphql/e2e/common/admin.go index 45f7b61a538..797d3c9327c 100644 --- a/graphql/e2e/common/admin.go +++ b/graphql/e2e/common/admin.go @@ -25,16 +25,16 @@ import ( "testing" "github.com/gogo/protobuf/jsonpb" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" "github.com/pkg/errors" + "github.com/stretchr/testify/require" "google.golang.org/grpc" "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/testutil" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" - "github.com/stretchr/testify/require" ) const ( diff --git a/graphql/e2e/common/common.go b/graphql/e2e/common/common.go index 8ce7e6ba1ae..173ffa765fd 100644 --- a/graphql/e2e/common/common.go +++ b/graphql/e2e/common/common.go @@ -30,15 +30,15 @@ import ( "time" "github.com/golang/glog" + "github.com/pkg/errors" + "github.com/stretchr/testify/require" + "google.golang.org/grpc" "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" - "github.com/stretchr/testify/require" - "google.golang.org/grpc" ) var ( @@ -599,26 +599,27 @@ func assertUpdateGqlSchemaUsingAdminSchemaEndpt(t *testing.T, authority, schema // To avoid issues, don't use space for indentation in expected input. // // The comparison requirements for JSON reported by /graphql are following: -// * The key order matters in object comparison, i.e. -// {"hello": "world", "foo": "bar"} -// is not same as: -// {"foo": "bar", "hello": "world"} -// * A key missing in an object is not same as that key present with value null, i.e. -// {"hello": "world"} -// is not same as: -// {"hello": "world", "foo": null} -// * Integers that are out of the [-(2^53)+1, (2^53)-1] precision range supported by JSON RFC, -// should still be encoded with full precision. i.e., the number 9007199254740993 ( = 2^53 + 1) -// should not get encoded as 9007199254740992 ( = 2^53). This happens in Go's standard JSON -// parser due to IEEE754 precision loss for floating point numbers. +// - The key order matters in object comparison, i.e. +// {"hello": "world", "foo": "bar"} +// is not same as: +// {"foo": "bar", "hello": "world"} +// - A key missing in an object is not same as that key present with value null, i.e. +// {"hello": "world"} +// is not same as: +// {"hello": "world", "foo": null} +// - Integers that are out of the [-(2^53)+1, (2^53)-1] precision range supported by JSON RFC, +// should still be encoded with full precision. i.e., the number 9007199254740993 ( = 2^53 + 1) +// should not get encoded as 9007199254740992 ( = 2^53). This happens in Go's standard JSON +// parser due to IEEE754 precision loss for floating point numbers. // // The above requirements are not satisfied by the standard require.JSONEq or testutil.CompareJSON // methods. // In order to satisfy all these requirements, this implementation just requires that the input // strings be equal after removing `\r`, `\n`, `\t` whitespace characters from the inputs. // TODO: -// Find a better way to do this such that order isn't mandated in list comparison. -// So that it is actually usable at places it is not used at present. +// +// Find a better way to do this such that order isn't mandated in list comparison. +// So that it is actually usable at places it is not used at present. func JSONEqGraphQL(t *testing.T, expected, actual string) { expected = strings.ReplaceAll(expected, "\r", "") expected = strings.ReplaceAll(expected, "\n", "") diff --git a/graphql/e2e/common/error.go b/graphql/e2e/common/error.go index 27caaf46296..48c6c9daf7f 100644 --- a/graphql/e2e/common/error.go +++ b/graphql/e2e/common/error.go @@ -27,20 +27,20 @@ import ( "strings" "testing" - admin2 "github.com/dgraph-io/dgraph/graphql/admin" + "github.com/google/go-cmp/cmp" + "github.com/stretchr/testify/require" + "google.golang.org/grpc" + "google.golang.org/grpc/peer" + "gopkg.in/yaml.v2" "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" dgoapi "github.com/dgraph-io/dgo/v210/protos/api" + admin2 "github.com/dgraph-io/dgraph/graphql/admin" "github.com/dgraph-io/dgraph/graphql/resolve" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/graphql/test" "github.com/dgraph-io/dgraph/x" - "github.com/google/go-cmp/cmp" - "github.com/stretchr/testify/require" - "google.golang.org/grpc" - "google.golang.org/grpc/peer" - "gopkg.in/yaml.v2" ) const ( diff --git a/graphql/e2e/common/fragment.go b/graphql/e2e/common/fragment.go index 4c566a6c8d3..28dfab15e4a 100644 --- a/graphql/e2e/common/fragment.go +++ b/graphql/e2e/common/fragment.go @@ -21,11 +21,11 @@ import ( "fmt" "testing" - "github.com/dgraph-io/dgraph/testutil" - "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/testutil" ) func fragmentInMutation(t *testing.T) { diff --git a/graphql/e2e/common/mutation.go b/graphql/e2e/common/mutation.go index 5e41e2f08dd..541ad83aece 100644 --- a/graphql/e2e/common/mutation.go +++ b/graphql/e2e/common/mutation.go @@ -28,14 +28,15 @@ import ( "sync" "testing" - "github.com/dgraph-io/dgo/v210" - "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/dgraph/testutil" - "github.com/dgraph-io/dgraph/x" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/stretchr/testify/require" "google.golang.org/grpc" + + "github.com/dgraph-io/dgo/v210" + "github.com/dgraph-io/dgo/v210/protos/api" + "github.com/dgraph-io/dgraph/testutil" + "github.com/dgraph-io/dgraph/x" ) // TestAddMutation tests that add mutations work as expected. There's a few angles diff --git a/graphql/e2e/common/query.go b/graphql/e2e/common/query.go index d2cfb0dc942..1cc8c7f7d15 100644 --- a/graphql/e2e/common/query.go +++ b/graphql/e2e/common/query.go @@ -29,20 +29,17 @@ import ( "testing" "time" - "github.com/dgraph-io/dgo/v210" - "github.com/dgraph-io/dgo/v210/protos/api" - "google.golang.org/grpc" - - "github.com/spf13/cast" - + "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/spf13/cast" + "github.com/stretchr/testify/require" + "google.golang.org/grpc" + "github.com/dgraph-io/dgo/v210" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/graphql/schema" - "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" - "github.com/google/go-cmp/cmp" - "github.com/stretchr/testify/require" ) func queryCountryByRegExp(t *testing.T, regexp string, expectedCountries []*country) { diff --git a/graphql/e2e/common/schema.go b/graphql/e2e/common/schema.go index 4338b85895a..36804a8ebd1 100644 --- a/graphql/e2e/common/schema.go +++ b/graphql/e2e/common/schema.go @@ -20,11 +20,12 @@ import ( "context" "testing" + "github.com/stretchr/testify/require" + "google.golang.org/grpc" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" - "github.com/stretchr/testify/require" - "google.golang.org/grpc" ) const ( diff --git a/graphql/e2e/common/subscription.go b/graphql/e2e/common/subscription.go index 0f15cbf1232..888c9787376 100644 --- a/graphql/e2e/common/subscription.go +++ b/graphql/e2e/common/subscription.go @@ -23,8 +23,9 @@ import ( "math/rand" "net/http" - "github.com/dgraph-io/dgraph/graphql/schema" "github.com/gorilla/websocket" + + "github.com/dgraph-io/dgraph/graphql/schema" ) // Reference: https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md diff --git a/graphql/e2e/custom_logic/custom_logic_test.go b/graphql/e2e/custom_logic/custom_logic_test.go index a5d1d7944be..41165721ca8 100644 --- a/graphql/e2e/custom_logic/custom_logic_test.go +++ b/graphql/e2e/custom_logic/custom_logic_test.go @@ -27,11 +27,12 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgraph/graphql/e2e/common" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" - "github.com/stretchr/testify/require" ) var ( diff --git a/graphql/e2e/directives/dgraph_directives_test.go b/graphql/e2e/directives/dgraph_directives_test.go index 6cdb7b9f47b..cf749031c12 100644 --- a/graphql/e2e/directives/dgraph_directives_test.go +++ b/graphql/e2e/directives/dgraph_directives_test.go @@ -21,11 +21,12 @@ import ( "os" "testing" + "github.com/pkg/errors" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgraph/graphql/e2e/common" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - "github.com/pkg/errors" - "github.com/stretchr/testify/require" ) func TestRunAll_WithDgraphDirectives(t *testing.T) { diff --git a/graphql/e2e/multi_tenancy/multi_tenancy_test.go b/graphql/e2e/multi_tenancy/multi_tenancy_test.go index fde0de60624..756721f7740 100644 --- a/graphql/e2e/multi_tenancy/multi_tenancy_test.go +++ b/graphql/e2e/multi_tenancy/multi_tenancy_test.go @@ -25,11 +25,11 @@ import ( "testing" "time" - "github.com/dgraph-io/dgraph/x" + "github.com/stretchr/testify/require" "github.com/dgraph-io/dgraph/graphql/e2e/common" "github.com/dgraph-io/dgraph/testutil" - "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgraph/x" ) const ( diff --git a/graphql/e2e/normal/normal_test.go b/graphql/e2e/normal/normal_test.go index b7ccb6415b6..b705229d22a 100644 --- a/graphql/e2e/normal/normal_test.go +++ b/graphql/e2e/normal/normal_test.go @@ -21,12 +21,12 @@ import ( "os" "testing" - "github.com/dgraph-io/dgraph/x" - "github.com/dgraph-io/ristretto/z" - - "github.com/dgraph-io/dgraph/graphql/e2e/common" "github.com/pkg/errors" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/graphql/e2e/common" + "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" ) func TestRunAll_Normal(t *testing.T) { diff --git a/graphql/e2e/schema/schema_test.go b/graphql/e2e/schema/schema_test.go index 497e1cacef7..dba7f33f2de 100644 --- a/graphql/e2e/schema/schema_test.go +++ b/graphql/e2e/schema/schema_test.go @@ -29,12 +29,13 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/graphql/e2e/common" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" - "github.com/stretchr/testify/require" ) var ( @@ -163,9 +164,9 @@ func TestSchemaSubscribe(t *testing.T) { // TestConcurrentSchemaUpdates checks that if there are too many concurrent requests to update the // GraphQL schema, then the system works as expected by either: -// 1. failing the schema update because there is another one in progress, OR -// 2. if the schema update succeeds, then the last successful schema update is reflected by both -// Dgraph and GraphQL schema +// 1. failing the schema update because there is another one in progress, OR +// 2. if the schema update succeeds, then the last successful schema update is reflected by both +// Dgraph and GraphQL schema // // It also tests that only one node exists for GraphQL schema in Dgraph after all the // concurrent requests have executed. diff --git a/graphql/e2e/subscription/subscription_test.go b/graphql/e2e/subscription/subscription_test.go index 63469a47c02..886065ca40a 100644 --- a/graphql/e2e/subscription/subscription_test.go +++ b/graphql/e2e/subscription/subscription_test.go @@ -23,12 +23,12 @@ import ( "testing" "time" - "github.com/dgraph-io/dgraph/x" + "github.com/stretchr/testify/require" "github.com/dgraph-io/dgraph/graphql/e2e/common" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/testutil" - "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgraph/x" ) var ( diff --git a/graphql/resolve/auth_test.go b/graphql/resolve/auth_test.go index 947081dac55..6a0e7e893a6 100644 --- a/graphql/resolve/auth_test.go +++ b/graphql/resolve/auth_test.go @@ -25,8 +25,9 @@ import ( "testing" "github.com/dgrijalva/jwt-go/v4" - + "github.com/stretchr/testify/require" "google.golang.org/grpc/metadata" + "gopkg.in/yaml.v2" dgoapi "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/dql" @@ -37,8 +38,6 @@ import ( "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" _ "github.com/dgraph-io/gqlparser/v2/validator/rules" // make gql validator init() all rules - "github.com/stretchr/testify/require" - "gopkg.in/yaml.v2" ) type AuthQueryRewritingCase struct { diff --git a/graphql/resolve/extensions_test.go b/graphql/resolve/extensions_test.go index 51d23e3002f..a3c18c50540 100644 --- a/graphql/resolve/extensions_test.go +++ b/graphql/resolve/extensions_test.go @@ -20,8 +20,9 @@ import ( "testing" "time" - "github.com/dgraph-io/dgraph/graphql/test" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/graphql/test" ) func TestQueriesPropagateExtensions(t *testing.T) { diff --git a/graphql/resolve/middlewares.go b/graphql/resolve/middlewares.go index d1831f0000f..55709cb4855 100644 --- a/graphql/resolve/middlewares.go +++ b/graphql/resolve/middlewares.go @@ -19,11 +19,12 @@ package resolve import ( "context" + "github.com/golang/glog" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/edgraph" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" - "github.com/pkg/errors" ) // QueryMiddleware represents a middleware for queries @@ -43,17 +44,23 @@ type QueryMiddlewares []QueryMiddleware type MutationMiddlewares []MutationMiddleware // Then chains the middlewares and returns the final QueryResolver. -// QueryMiddlewares{m1, m2, m3}.Then(r) +// +// QueryMiddlewares{m1, m2, m3}.Then(r) +// // is equivalent to: -// m1(m2(m3(r))) +// +// m1(m2(m3(r))) +// // When the request comes in, it will be passed to m1, then m2, then m3 // and finally, the given resolverFunc // (assuming every middleware calls the following one). // // A chain can be safely reused by calling Then() several times. -// commonMiddlewares := QueryMiddlewares{authMiddleware, loggingMiddleware} -// healthResolver = commonMiddlewares.Then(resolveHealth) -// stateResolver = commonMiddlewares.Then(resolveState) +// +// commonMiddlewares := QueryMiddlewares{authMiddleware, loggingMiddleware} +// healthResolver = commonMiddlewares.Then(resolveHealth) +// stateResolver = commonMiddlewares.Then(resolveState) +// // Note that middlewares are called on every call to Then() // and thus several instances of the same middleware will be created // when a chain is reused in this way. @@ -76,17 +83,23 @@ func (mws QueryMiddlewares) Then(resolver QueryResolver) QueryResolver { } // Then chains the middlewares and returns the final MutationResolver. -// MutationMiddlewares{m1, m2, m3}.Then(r) +// +// MutationMiddlewares{m1, m2, m3}.Then(r) +// // is equivalent to: -// m1(m2(m3(r))) +// +// m1(m2(m3(r))) +// // When the request comes in, it will be passed to m1, then m2, then m3 // and finally, the given resolverFunc // (assuming every middleware calls the following one). // // A chain can be safely reused by calling Then() several times. -// commonMiddlewares := MutationMiddlewares{authMiddleware, loggingMiddleware} -// backupResolver = commonMiddlewares.Then(resolveBackup) -// configResolver = commonMiddlewares.Then(resolveConfig) +// +// commonMiddlewares := MutationMiddlewares{authMiddleware, loggingMiddleware} +// backupResolver = commonMiddlewares.Then(resolveBackup) +// configResolver = commonMiddlewares.Then(resolveConfig) +// // Note that middlewares are called on every call to Then() // and thus several instances of the same middleware will be created // when a chain is reused in this way. diff --git a/graphql/resolve/middlewares_test.go b/graphql/resolve/middlewares_test.go index 7b5ba91aa05..715bc95a90c 100644 --- a/graphql/resolve/middlewares_test.go +++ b/graphql/resolve/middlewares_test.go @@ -20,8 +20,9 @@ import ( "context" "testing" - "github.com/dgraph-io/dgraph/graphql/schema" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/graphql/schema" ) func TestQueryMiddlewares_Then_ExecutesMiddlewaresInOrder(t *testing.T) { diff --git a/graphql/resolve/mutation.go b/graphql/resolve/mutation.go index 46b0582c57e..108a14a3d2d 100644 --- a/graphql/resolve/mutation.go +++ b/graphql/resolve/mutation.go @@ -24,14 +24,15 @@ import ( "sort" "strconv" + "github.com/golang/glog" + "github.com/pkg/errors" + otrace "go.opencensus.io/trace" + dgoapi "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/dql" "github.com/dgraph-io/dgraph/graphql/dgraph" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" - "github.com/pkg/errors" - otrace "go.opencensus.io/trace" ) const touchedUidsKey = "_total" diff --git a/graphql/resolve/mutation_rewriter.go b/graphql/resolve/mutation_rewriter.go index 3df03b1bed6..6df112c54d1 100644 --- a/graphql/resolve/mutation_rewriter.go +++ b/graphql/resolve/mutation_rewriter.go @@ -25,12 +25,12 @@ import ( "strconv" "strings" + "github.com/pkg/errors" + dgoapi "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/dql" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/x" - - "github.com/pkg/errors" ) const ( diff --git a/graphql/resolve/mutation_test.go b/graphql/resolve/mutation_test.go index 7c2c3186d35..9ac6af5426b 100644 --- a/graphql/resolve/mutation_test.go +++ b/graphql/resolve/mutation_test.go @@ -24,15 +24,15 @@ import ( "strings" "testing" - dgoapi "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/dgraph/testutil" + "github.com/stretchr/testify/require" + "gopkg.in/yaml.v2" + dgoapi "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/graphql/dgraph" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/graphql/test" + "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" - "github.com/stretchr/testify/require" - "gopkg.in/yaml.v2" ) // Tests showing that GraphQL mutations -> Dgraph mutations diff --git a/graphql/resolve/query_rewriter.go b/graphql/resolve/query_rewriter.go index dc32f6c49bd..7c58ddc0d02 100644 --- a/graphql/resolve/query_rewriter.go +++ b/graphql/resolve/query_rewriter.go @@ -24,11 +24,12 @@ import ( "strconv" "strings" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/dql" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" ) type queryRewriter struct{} diff --git a/graphql/resolve/query_test.go b/graphql/resolve/query_test.go index 3b5cab3f7f3..35440e90953 100644 --- a/graphql/resolve/query_test.go +++ b/graphql/resolve/query_test.go @@ -24,13 +24,14 @@ import ( "net/http" "testing" + "github.com/stretchr/testify/require" + "gopkg.in/yaml.v2" + "github.com/dgraph-io/dgraph/graphql/dgraph" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/graphql/test" "github.com/dgraph-io/dgraph/testutil" _ "github.com/dgraph-io/gqlparser/v2/validator/rules" // make gql validator init() all rules - "github.com/stretchr/testify/require" - "gopkg.in/yaml.v2" ) // Tests showing that the query rewriter produces the expected Dgraph queries diff --git a/graphql/resolve/resolver.go b/graphql/resolve/resolver.go index cb876a98264..ea128f89399 100644 --- a/graphql/resolve/resolver.go +++ b/graphql/resolve/resolver.go @@ -25,17 +25,16 @@ import ( "sync" "time" + "github.com/golang/glog" + "github.com/pkg/errors" + otrace "go.opencensus.io/trace" + dgoapi "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/edgraph" "github.com/dgraph-io/dgraph/graphql/api" "github.com/dgraph-io/dgraph/graphql/dgraph" - "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" - otrace "go.opencensus.io/trace" - - "github.com/golang/glog" - "github.com/dgraph-io/dgraph/graphql/schema" + "github.com/dgraph-io/dgraph/x" ) type resolveCtxKey string diff --git a/graphql/resolve/resolver_error_test.go b/graphql/resolve/resolver_error_test.go index 57c8a36457f..218dbc464a7 100644 --- a/graphql/resolve/resolver_error_test.go +++ b/graphql/resolve/resolver_error_test.go @@ -23,14 +23,15 @@ import ( "sync" "testing" - dgoapi "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/dgraph/graphql/schema" - "github.com/dgraph-io/dgraph/graphql/test" - "github.com/dgraph-io/dgraph/x" "github.com/google/go-cmp/cmp" "github.com/pkg/errors" "github.com/stretchr/testify/require" "gopkg.in/yaml.v2" + + dgoapi "github.com/dgraph-io/dgo/v210/protos/api" + "github.com/dgraph-io/dgraph/graphql/schema" + "github.com/dgraph-io/dgraph/graphql/test" + "github.com/dgraph-io/dgraph/x" ) // Tests that result completion and GraphQL error propagation are working properly. diff --git a/graphql/resolve/resolver_test.go b/graphql/resolve/resolver_test.go index 0b61b63885c..6cb19ea17c5 100644 --- a/graphql/resolve/resolver_test.go +++ b/graphql/resolve/resolver_test.go @@ -19,12 +19,12 @@ package resolve import ( "testing" - "github.com/dgraph-io/dgraph/graphql/schema" + "github.com/google/go-cmp/cmp" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/graphql/test" "github.com/dgraph-io/dgraph/x" - "github.com/google/go-cmp/cmp" - "github.com/stretchr/testify/require" ) func TestErrorOnIncorrectValueType(t *testing.T) { diff --git a/graphql/run.go b/graphql/run.go index d3c584b645c..22e99bf92c9 100644 --- a/graphql/run.go +++ b/graphql/run.go @@ -19,7 +19,6 @@ // GraphQL spec: // https://graphql.github.io/graphql-spec/June2018 // -// // GraphQL servers should serve both GET and POST // https://graphql.org/learn/serving-over-http/ // @@ -27,35 +26,37 @@ // http://myapi/graphql?query={me{name}} // // POST should have a json content body like -// { -// "query": "...", -// "operationName": "...", -// "variables": { "myVariable": "someValue", ... } -// } +// +// { +// "query": "...", +// "operationName": "...", +// "variables": { "myVariable": "someValue", ... } +// } // // GraphQL servers should return 200 (even on errors), // and result body should be json: -// { -// "data": { "query_name" : { ... } }, -// "errors": [ { "message" : ..., ...} ... ] -// } +// +// { +// "data": { "query_name" : { ... } }, +// "errors": [ { "message" : ..., ...} ... ] +// } // // Key points about the response // (https://graphql.github.io/graphql-spec/June2018/#sec-Response) // -// - If an error was encountered before execution begins, -// the data entry should not be present in the result. +// - If an error was encountered before execution begins, +// the data entry should not be present in the result. // -// - If an error was encountered during the execution that -// prevented a valid response, the data entry in the response should be null. +// - If an error was encountered during the execution that +// prevented a valid response, the data entry in the response should be null. // // - If there's errors and data, both are returned // -// - If no errors were encountered during the requested operation, -// the errors entry should not be present in the result. +// - If no errors were encountered during the requested operation, +// the errors entry should not be present in the result. // -// - There's rules around how errors work when there's ! fields in the schema -// https://graphql.github.io/graphql-spec/June2018/#sec-Errors-and-Non-Nullability +// - There's rules around how errors work when there's ! fields in the schema +// https://graphql.github.io/graphql-spec/June2018/#sec-Errors-and-Non-Nullability // // - The "message" in an error is required, the rest is up to the implementation // diff --git a/graphql/schema/completion.go b/graphql/schema/completion.go index 6eac72509b6..dc2090d361d 100644 --- a/graphql/schema/completion.go +++ b/graphql/schema/completion.go @@ -70,16 +70,18 @@ func Unmarshal(data []byte, v interface{}) error { // CompleteObject builds a json GraphQL result object for the current query level. // It returns a bracketed json object like { f1:..., f2:..., ... }. // At present, it is only used for building custom results by: -// * Admin Server -// * @custom(http: {...}) query/mutation -// * @custom(dql: ...) queries +// - Admin Server +// - @custom(http: {...}) query/mutation +// - @custom(dql: ...) queries // // fields are all the fields from this bracketed level in the GraphQL query, e.g: -// { -// name -// dob -// friends {...} -// } +// +// { +// name +// dob +// friends {...} +// } +// // If it's the top level of a query then it'll be the top level query name. // // typ is the expected type matching those fields, e.g. above that'd be something @@ -331,13 +333,15 @@ func mismatched(path []interface{}, field Field) ([]byte, x.GqlErrorList) { // defined in the GraphQL spec. If this is not possible, then it returns an error. The crux of // coercion rules defined in the spec is to not lose information during coercion. // Note that, admin server specifically uses these: -// * json.Number -// * schema.Unmarshal() everywhere else +// - json.Number +// - schema.Unmarshal() everywhere else +// // And, @custom(http: {...}) query/mutation would always use schema.Unmarshal(). // Now, schema.Unmarshal() can only give one of the following types for scalars: -// * bool -// * string -// * json.Number (because it uses custom JSON decoder which preserves number precision) +// - bool +// - string +// - json.Number (because it uses custom JSON decoder which preserves number precision) +// // So, we need to consider only these cases at present. func coerceScalar(val interface{}, field Field, path []interface{}) (interface{}, x.GqlErrorList) { diff --git a/graphql/schema/custom_http.go b/graphql/schema/custom_http.go index 5dd7238ed97..0a6169cb85b 100644 --- a/graphql/schema/custom_http.go +++ b/graphql/schema/custom_http.go @@ -27,7 +27,6 @@ import ( "time" "github.com/dgraph-io/dgraph/graphql/authorization" - "github.com/dgraph-io/dgraph/x" ) diff --git a/graphql/schema/errors.go b/graphql/schema/errors.go index 83e8ee7c963..39a68532406 100644 --- a/graphql/schema/errors.go +++ b/graphql/schema/errors.go @@ -19,9 +19,8 @@ package schema import ( "fmt" - "github.com/dgraph-io/gqlparser/v2/ast" - "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/gqlparser/v2/ast" "github.com/dgraph-io/gqlparser/v2/gqlerror" ) diff --git a/graphql/schema/errors_test.go b/graphql/schema/errors_test.go index c69232cd2f3..d3f31fea4ac 100644 --- a/graphql/schema/errors_test.go +++ b/graphql/schema/errors_test.go @@ -21,11 +21,11 @@ import ( "errors" "testing" - "github.com/dgraph-io/dgraph/x" - "github.com/dgraph-io/gqlparser/v2/gqlerror" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/stretchr/testify/assert" + "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/gqlparser/v2/gqlerror" ) func TestGQLWrapf_Error(t *testing.T) { diff --git a/graphql/schema/introspection.go b/graphql/schema/introspection.go index a87cf251edb..9d393e2b021 100644 --- a/graphql/schema/introspection.go +++ b/graphql/schema/introspection.go @@ -470,7 +470,7 @@ func (ec *executionContext) marshalType(sel ast.SelectionSet, v *introspection.T } // Returns all the types associated with the schema, including the ones that are part -//of introspection system (i.e., the type name begins with __ ) +// of introspection system (i.e., the type name begins with __ ) func getAllTypes(s *ast.Schema) []introspection.Type { types := make([]introspection.Type, 0, len(s.Types)) for _, typ := range s.Types { diff --git a/graphql/schema/remote.go b/graphql/schema/remote.go index b96ee623528..ed364384e49 100644 --- a/graphql/schema/remote.go +++ b/graphql/schema/remote.go @@ -25,8 +25,9 @@ import ( "net/url" "time" - "github.com/dgraph-io/gqlparser/v2/ast" "github.com/pkg/errors" + + "github.com/dgraph-io/gqlparser/v2/ast" ) func validateUrl(rawURL string) error { diff --git a/graphql/schema/request.go b/graphql/schema/request.go index 5ccdf242501..3660f646264 100644 --- a/graphql/schema/request.go +++ b/graphql/schema/request.go @@ -108,41 +108,42 @@ func (s *schema) Operation(req *Request) (Operation, error) { // field's selection set, and does it recursively for all the fields in this field's selection // set. This eventually expands all the fragment references anywhere in the hierarchy. // To understand how expansion works, let's consider following graphql schema (Reference: Starwars): -// interface Employee { ... } -// interface Character { ... } -// type Human implements Character & Employee { ... } -// type Droid implements Character { ... } -// 1. field returns an Interface: Consider executing following query: -// query { -// queryCharacter { -// ...commonCharacterFrag -// ...humanFrag -// ...droidFrag -// } -// } -// fragment commonCharacterFrag on Character { ... } -// fragment humanFrag on Human { ... } -// fragment droidFrag on Droid { ... } -// As queryCharacter returns Characters, so any fragment reference used inside queryCharacter and -// defined on Character interface should be expanded. Also, any fragments defined on the types -// which implement Character interface should also be expanded. That means, any fragments on -// Character, Human and Droid will be expanded in the result of queryCharacter. -// 2. field returns an Object: Consider executing following query: -// query { -// queryHuman { -// ...employeeFrag -// ...characterFrag -// ...humanFrag -// } -// } -// fragment employeeFrag on Employee { ... } -// fragment characterFrag on Character { ... } -// fragment humanFrag on Human { ... } -// As queryHuman returns Humans, so any fragment reference used inside queryHuman and -// defined on Human type should be expanded. Also, any fragments defined on the interfaces -// which are implemented by Human type should also be expanded. That means, any fragments on -// Human, Character and Employee will be expanded in the result of queryHuman. -// 3. field returns a Union: process is similar to the case when field returns an interface. +// +// interface Employee { ... } +// interface Character { ... } +// type Human implements Character & Employee { ... } +// type Droid implements Character { ... } +// 1. field returns an Interface: Consider executing following query: +// query { +// queryCharacter { +// ...commonCharacterFrag +// ...humanFrag +// ...droidFrag +// } +// } +// fragment commonCharacterFrag on Character { ... } +// fragment humanFrag on Human { ... } +// fragment droidFrag on Droid { ... } +// As queryCharacter returns Characters, so any fragment reference used inside queryCharacter and +// defined on Character interface should be expanded. Also, any fragments defined on the types +// which implement Character interface should also be expanded. That means, any fragments on +// Character, Human and Droid will be expanded in the result of queryCharacter. +// 2. field returns an Object: Consider executing following query: +// query { +// queryHuman { +// ...employeeFrag +// ...characterFrag +// ...humanFrag +// } +// } +// fragment employeeFrag on Employee { ... } +// fragment characterFrag on Character { ... } +// fragment humanFrag on Human { ... } +// As queryHuman returns Humans, so any fragment reference used inside queryHuman and +// defined on Human type should be expanded. Also, any fragments defined on the interfaces +// which are implemented by Human type should also be expanded. That means, any fragments on +// Human, Character and Employee will be expanded in the result of queryHuman. +// 3. field returns a Union: process is similar to the case when field returns an interface. func recursivelyExpandFragmentSelections(field *ast.Field, op *operation) { // This happens in case of introspection queries, as they don't have any types in graphql schema // but explicit resolvers defined. So, when the parser parses the raw request, it is not able to diff --git a/graphql/schema/response.go b/graphql/schema/response.go index 7900f3d4ebc..cd27a14a19d 100644 --- a/graphql/schema/response.go +++ b/graphql/schema/response.go @@ -249,7 +249,7 @@ func (t *Trace) Merge(other *Trace) { } } -//ExecutionTrace records all the resolvers +// ExecutionTrace records all the resolvers type ExecutionTrace struct { Resolvers []*ResolverTrace `json:"resolvers"` } diff --git a/graphql/schema/response_test.go b/graphql/schema/response_test.go index b36a9e0b83f..3d4a4621c8d 100644 --- a/graphql/schema/response_test.go +++ b/graphql/schema/response_test.go @@ -20,10 +20,11 @@ import ( "bytes" "testing" - "github.com/dgraph-io/dgraph/x" - "github.com/dgraph-io/gqlparser/v2/gqlerror" "github.com/pkg/errors" "github.com/stretchr/testify/assert" + + "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/gqlparser/v2/gqlerror" ) func TestDataAndErrors(t *testing.T) { diff --git a/graphql/schema/schemagen.go b/graphql/schema/schemagen.go index e9f73da7ba2..30236622e6d 100644 --- a/graphql/schema/schemagen.go +++ b/graphql/schema/schemagen.go @@ -23,13 +23,14 @@ import ( "sort" "strings" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/graphql/authorization" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/gqlparser/v2/ast" "github.com/dgraph-io/gqlparser/v2/gqlerror" "github.com/dgraph-io/gqlparser/v2/parser" "github.com/dgraph-io/gqlparser/v2/validator" - "github.com/pkg/errors" ) // A Handler can produce valid GraphQL and Dgraph schemas given an input of diff --git a/graphql/schema/schemagen_test.go b/graphql/schema/schemagen_test.go index 0dcd3215da1..fe764fa0c91 100644 --- a/graphql/schema/schemagen_test.go +++ b/graphql/schema/schemagen_test.go @@ -22,16 +22,16 @@ import ( "strings" "testing" + "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/stretchr/testify/require" + "gopkg.in/yaml.v2" dschema "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/gqlparser/v2/gqlerror" _ "github.com/dgraph-io/gqlparser/v2/validator/rules" "github.com/dgraph-io/ristretto/z" - "github.com/google/go-cmp/cmp" - "github.com/stretchr/testify/require" - "gopkg.in/yaml.v2" ) type Tests map[string][]TestCase diff --git a/graphql/schema/wrappers.go b/graphql/schema/wrappers.go index dc46e73b774..0c518419f87 100644 --- a/graphql/schema/wrappers.go +++ b/graphql/schema/wrappers.go @@ -26,12 +26,12 @@ import ( "strconv" "strings" - "github.com/dgraph-io/dgraph/graphql/authorization" - "github.com/dgraph-io/gqlparser/v2/parser" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/graphql/authorization" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/gqlparser/v2/ast" - "github.com/pkg/errors" + "github.com/dgraph-io/gqlparser/v2/parser" ) // Wrap the github.com/dgraph-io/gqlparser/ast defintions so that the bulk of the GraphQL @@ -454,14 +454,15 @@ func (o *operation) CacheControl() string { // typDef inherited from. If there is no such interface, then it returns an empty string. // // Given the following schema -// interface A { -// name: String -// } // -// type B implements A { -// name: String -// age: Int -// } +// interface A { +// name: String +// } +// +// type B implements A { +// name: String +// age: Int +// } // // calling parentInterface on the fieldName name with type definition for B, would return A. func parentInterface(sch *ast.Schema, typDef *ast.Definition, fieldName string) *ast.Definition { @@ -674,24 +675,24 @@ func typeMappings(s *ast.Schema) map[string][]*ast.Definition { } // customAndLambdaMappings does following things: -// * If there is @custom on any field, it removes the directive from the list of directives on -// that field. Instead, it puts it in a map of typeName->fieldName->custom directive definition. -// This mapping is returned as the first return value, which is later used to determine if some -// field has custom directive or not, and accordingly construct the HTTP request for the field. -// * If there is @lambda on any field, it removes the directive from the list of directives on -// that field. Instead, it puts it in a map of typeName->fieldName->bool. This mapping is returned -// as the second return value, which is later used to determine if some field has lambda directive -// or not. An appropriate @custom directive is also constructed for the field with @lambda and -// put into the first mapping. Both of these mappings together are used to construct the HTTP -// request for @lambda field. Internally, @lambda is just @custom(http: { -// url: "", -// method: POST, -// body: "/" -// mode: BATCH (set only if @lambda was on a non query/mutation field) -// }) -// So, by constructing an appropriate custom directive for @lambda fields, -// we just reuse logic from @custom. +// - If there is @custom on any field, it removes the directive from the list of directives on +// that field. Instead, it puts it in a map of typeName->fieldName->custom directive definition. +// This mapping is returned as the first return value, which is later used to determine if some +// field has custom directive or not, and accordingly construct the HTTP request for the field. +// - If there is @lambda on any field, it removes the directive from the list of directives on +// that field. Instead, it puts it in a map of typeName->fieldName->bool. This mapping is returned +// as the second return value, which is later used to determine if some field has lambda directive +// or not. An appropriate @custom directive is also constructed for the field with @lambda and +// put into the first mapping. Both of these mappings together are used to construct the HTTP +// request for @lambda field. Internally, @lambda is just @custom(http: { +// url: "", +// method: POST, +// body: "/" +// mode: BATCH (set only if @lambda was on a non query/mutation field) +// }) +// So, by constructing an appropriate custom directive for @lambda fields, +// we just reuse logic from @custom. func customAndLambdaMappings(s *ast.Schema, ns uint64) (map[string]map[string]*ast.Directive, map[string]map[string]bool) { customDirectives := make(map[string]map[string]*ast.Directive) @@ -874,6 +875,7 @@ func externalAndNonKeyField(fld *ast.FieldDefinition, defn *ast.Definition, prov // buildCustomDirectiveForLambda returns custom directive for the given field to be used for @lambda // The constructed @custom looks like this: +// // @custom(http: { // url: "", // method: POST, @@ -2670,33 +2672,33 @@ func (t *astType) ImplementingTypes() []Type { // // For our reference types for adding/linking objects, we'd like to have something like // -// input PostRef { -// id: ID! -// } +// input PostRef { +// id: ID! +// } // -// input PostNew { -// title: String! -// text: String -// author: AuthorRef! -// } +// input PostNew { +// title: String! +// text: String +// author: AuthorRef! +// } // // and then have something like this // // input PostNewOrReference = PostRef | PostNew // -// input AuthorNew { -// ... -// posts: [PostNewOrReference] -// } +// input AuthorNew { +// ... +// posts: [PostNewOrReference] +// } // // but GraphQL doesn't allow union types in input, so best we can do is // -// input PostRef { -// id: ID -// title: String -// text: String -// author: AuthorRef -// } +// input PostRef { +// id: ID +// title: String +// text: String +// author: AuthorRef +// } // // and then check ourselves that either there's an ID, or there's all the bits to // satisfy a valid post. @@ -2983,24 +2985,27 @@ func substituteVarInSliceInBody(slice []interface{}, variables map[string]interf // Given a JSON representation for a body with variables defined, this function substitutes // the variables and returns the final JSON. // for e.g. -// { -// "author" : "$id", -// "name" : "Jerry", -// "age" : 23, -// "post": { -// "id": "$postID" -// } -// } +// +// { +// "author" : "$id", +// "name" : "Jerry", +// "age" : 23, +// "post": { +// "id": "$postID" +// } +// } +// // with variables {"id": "0x3", postID: "0x9"} // should return -// { -// "author" : "0x3", -// "name" : "Jerry", -// "age" : 23, -// "post": { -// "id": "0x9" -// } -// } +// +// { +// "author" : "0x3", +// "name" : "Jerry", +// "age" : 23, +// "post": { +// "id": "0x9" +// } +// } func SubstituteVarsInBody(jsonTemplate interface{}, variables map[string]interface{}) interface{} { if jsonTemplate == nil { return nil @@ -3040,19 +3045,22 @@ func (t *astType) FieldOriginatedFrom(fieldName string) string { // buildGraphqlRequestFields will build graphql request body from ast. // for eg: -// Hello{ -// name { -// age -// } -// friend -// } +// +// Hello{ +// name { +// age +// } +// friend +// } +// // will return -// { -// name { -// age -// } -// friend -// } +// +// { +// name { +// age +// } +// friend +// } func buildGraphqlRequestFields(writer *bytes.Buffer, field *ast.Field) { // Add beginning curly braces if len(field.SelectionSet) == 0 { diff --git a/graphql/schema/wrappers_test.go b/graphql/schema/wrappers_test.go index 9d0c128593f..6820813b3cc 100644 --- a/graphql/schema/wrappers_test.go +++ b/graphql/schema/wrappers_test.go @@ -22,13 +22,13 @@ import ( "strings" "testing" - "github.com/dgraph-io/dgraph/x" - - "github.com/dgraph-io/gqlparser/v2/ast" "github.com/google/go-cmp/cmp" "github.com/pkg/errors" "github.com/stretchr/testify/require" "gopkg.in/yaml.v2" + + "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/gqlparser/v2/ast" ) func TestDgraphMapping_WithoutDirectives(t *testing.T) { diff --git a/graphql/subscription/poller.go b/graphql/subscription/poller.go index b80b9616c5c..5c206ae8bba 100644 --- a/graphql/subscription/poller.go +++ b/graphql/subscription/poller.go @@ -26,12 +26,12 @@ import ( "time" "github.com/dgrijalva/jwt-go/v4" + "github.com/dgryski/go-farm" + "github.com/golang/glog" "github.com/dgraph-io/dgraph/graphql/resolve" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/x" - "github.com/dgryski/go-farm" - "github.com/golang/glog" ) // Poller is used to poll user subscription query. diff --git a/graphql/test/test.go b/graphql/test/test.go index e1673a12259..d2e8c06f781 100644 --- a/graphql/test/test.go +++ b/graphql/test/test.go @@ -21,13 +21,13 @@ import ( "io/ioutil" "testing" - "github.com/dgraph-io/dgraph/x" + "github.com/stretchr/testify/require" "github.com/dgraph-io/dgraph/graphql/schema" + "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/gqlparser/v2/ast" "github.com/dgraph-io/gqlparser/v2/parser" "github.com/dgraph-io/gqlparser/v2/validator" - "github.com/stretchr/testify/require" ) // Various helpers used in GQL testing diff --git a/graphql/testdata/datagen/cmd/root.go b/graphql/testdata/datagen/cmd/root.go index 9b8d28311df..d6f4efe516d 100644 --- a/graphql/testdata/datagen/cmd/root.go +++ b/graphql/testdata/datagen/cmd/root.go @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/graphql/testdata/datagen/main.go b/graphql/testdata/datagen/main.go index 4e8e6447145..0a46a35de35 100644 --- a/graphql/testdata/datagen/main.go +++ b/graphql/testdata/datagen/main.go @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/lex/lexer.go b/lex/lexer.go index e0c40128dcf..061e1548cd9 100644 --- a/lex/lexer.go +++ b/lex/lexer.go @@ -20,8 +20,9 @@ import ( "fmt" "unicode/utf8" - "github.com/dgraph-io/dgraph/x" "github.com/pkg/errors" + + "github.com/dgraph-io/dgraph/x" ) // EOF indicates the end of the an input. diff --git a/posting/index_test.go b/posting/index_test.go index 5c54cc0db97..756cb25f198 100644 --- a/posting/index_test.go +++ b/posting/index_test.go @@ -23,9 +23,9 @@ import ( "testing" "time" - "github.com/dgraph-io/badger/v3" "github.com/stretchr/testify/require" + "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/types" diff --git a/posting/list.go b/posting/list.go index 40c96175454..a3c932b7f89 100644 --- a/posting/list.go +++ b/posting/list.go @@ -25,6 +25,7 @@ import ( "sort" "github.com/dgryski/go-farm" + "github.com/golang/protobuf/proto" "github.com/pkg/errors" bpb "github.com/dgraph-io/badger/v3/pb" @@ -37,7 +38,6 @@ import ( "github.com/dgraph-io/dgraph/types/facets" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - "github.com/golang/protobuf/proto" ) var ( diff --git a/posting/list_test.go b/posting/list_test.go index 5decc303572..57e1936b567 100644 --- a/posting/list_test.go +++ b/posting/list_test.go @@ -26,17 +26,17 @@ import ( "strconv" "testing" - "github.com/dgraph-io/badger/v3" - bpb "github.com/dgraph-io/badger/v3/pb" - "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/ristretto/z" "github.com/google/uuid" "github.com/stretchr/testify/require" + "github.com/dgraph-io/badger/v3" + bpb "github.com/dgraph-io/badger/v3/pb" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/codec" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" ) func setMaxListSize(newMaxListSize int) { diff --git a/posting/lists.go b/posting/lists.go index 55063a68ecf..f8de51e1f5f 100644 --- a/posting/lists.go +++ b/posting/lists.go @@ -26,11 +26,10 @@ import ( "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/ristretto" - "github.com/dgraph-io/ristretto/z" - "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto" + "github.com/dgraph-io/ristretto/z" ) const ( diff --git a/posting/mvcc.go b/posting/mvcc.go index 3bfdf949197..279d46df319 100644 --- a/posting/mvcc.go +++ b/posting/mvcc.go @@ -25,15 +25,16 @@ import ( "sync/atomic" "time" + "github.com/golang/glog" + "github.com/golang/protobuf/proto" + "github.com/pkg/errors" + "github.com/dgraph-io/badger/v3" bpb "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - "github.com/golang/glog" - "github.com/golang/protobuf/proto" - "github.com/pkg/errors" ) type pooledKeys struct { diff --git a/posting/mvcc_test.go b/posting/mvcc_test.go index 0aa1a5d60c2..7fbec1931ea 100644 --- a/posting/mvcc_test.go +++ b/posting/mvcc_test.go @@ -20,9 +20,10 @@ import ( "math" "testing" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" - "github.com/stretchr/testify/require" ) func TestRollupTimestamp(t *testing.T) { diff --git a/posting/oracle.go b/posting/oracle.go index 31b914a0f93..7a13c37604f 100644 --- a/posting/oracle.go +++ b/posting/oracle.go @@ -23,10 +23,11 @@ import ( "sync/atomic" "time" - "github.com/dgraph-io/dgraph/protos/pb" - "github.com/dgraph-io/dgraph/x" "github.com/golang/glog" ostats "go.opencensus.io/stats" + + "github.com/dgraph-io/dgraph/protos/pb" + "github.com/dgraph-io/dgraph/x" ) var o *oracle diff --git a/posting/size_test.go b/posting/size_test.go index 406ce6118ca..323184cf1f0 100644 --- a/posting/size_test.go +++ b/posting/size_test.go @@ -22,6 +22,7 @@ import ( "io/ioutil" "log" "math" + _ "net/http/pprof" "os" "os/exec" "runtime" @@ -30,15 +31,13 @@ import ( "strings" "testing" - _ "net/http/pprof" + "github.com/dustin/go-humanize" + "github.com/pkg/errors" + "github.com/stretchr/testify/require" "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/protos/pb" - "github.com/dustin/go-humanize" - "github.com/pkg/errors" - - "github.com/stretchr/testify/require" ) var manual = flag.Bool("manual", false, "Set when manually running some tests.") diff --git a/posting/writer.go b/posting/writer.go index a667b399fc0..7ecaf5c7623 100644 --- a/posting/writer.go +++ b/posting/writer.go @@ -20,9 +20,10 @@ import ( "math" "sync" + "github.com/golang/glog" + "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/badger/v3/pb" - "github.com/golang/glog" ) // TxnWriter is in charge or writing transactions to badger. diff --git a/posting/writer_test.go b/posting/writer_test.go index b926291d0f8..4dba68271ae 100644 --- a/posting/writer_test.go +++ b/posting/writer_test.go @@ -24,10 +24,11 @@ import ( "sync" "testing" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/badger/v3/options" bpb "github.com/dgraph-io/badger/v3/pb" - "github.com/stretchr/testify/require" ) var val = make([]byte, 128) diff --git a/protos/protos_test.go b/protos/protos_test.go index 4c79113ab7a..5205c93a165 100644 --- a/protos/protos_test.go +++ b/protos/protos_test.go @@ -19,8 +19,9 @@ import ( "path/filepath" "testing" - "github.com/dgraph-io/dgraph/testutil" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/testutil" ) func TestProtosRegenerate(t *testing.T) { diff --git a/query/aggregator.go b/query/aggregator.go index b698753788b..003bc6280fc 100644 --- a/query/aggregator.go +++ b/query/aggregator.go @@ -21,10 +21,11 @@ import ( "math" "time" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" ) type aggregator struct { diff --git a/query/fastjson_test.go b/query/fastjson_test.go index f0a64258b9f..e6e065830a8 100644 --- a/query/fastjson_test.go +++ b/query/fastjson_test.go @@ -5,11 +5,12 @@ import ( "math" "testing" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/task" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/types" - "github.com/stretchr/testify/require" ) func subgraphWithSingleResultAndSingleValue(val *pb.TaskValue) *SubGraph { diff --git a/query/groupby.go b/query/groupby.go index 24c35ecc5cd..87a3825aae2 100644 --- a/query/groupby.go +++ b/query/groupby.go @@ -21,10 +21,11 @@ import ( "sort" "strconv" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/algo" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/types" - "github.com/pkg/errors" ) type groupPair struct { diff --git a/query/math.go b/query/math.go index 60e6315b67e..44574f52ece 100644 --- a/query/math.go +++ b/query/math.go @@ -17,9 +17,10 @@ package query import ( - "github.com/dgraph-io/dgraph/types" "github.com/golang/glog" "github.com/pkg/errors" + + "github.com/dgraph-io/dgraph/types" ) type mathTree struct { diff --git a/query/math_test.go b/query/math_test.go index ec24b2280c0..e1f17f3b542 100644 --- a/query/math_test.go +++ b/query/math_test.go @@ -20,8 +20,9 @@ import ( "math" "testing" - "github.com/dgraph-io/dgraph/types" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/types" ) func TestProcessBinary(t *testing.T) { diff --git a/query/mutation.go b/query/mutation.go index eaf54a49c19..5ebfd4f3609 100644 --- a/query/mutation.go +++ b/query/mutation.go @@ -21,6 +21,8 @@ import ( "strings" "time" + "github.com/golang/glog" + "github.com/pkg/errors" otrace "go.opencensus.io/trace" "github.com/dgraph-io/dgo/v210/protos/api" @@ -29,8 +31,6 @@ import ( "github.com/dgraph-io/dgraph/types/facets" "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" - "github.com/pkg/errors" ) // ApplyMutations performs the required edge expansions and forwards the results to the diff --git a/query/mutation_test.go b/query/mutation_test.go index 3d305e7b68f..289a9d6623d 100644 --- a/query/mutation_test.go +++ b/query/mutation_test.go @@ -21,9 +21,10 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" - "github.com/stretchr/testify/require" ) func TestReserverPredicateForMutation(t *testing.T) { diff --git a/query/outputnode.go b/query/outputnode.go index 95759e10026..0dfb75a5fa6 100644 --- a/query/outputnode.go +++ b/query/outputnode.go @@ -30,8 +30,6 @@ import ( "unicode/utf8" "unsafe" - gqlSchema "github.com/dgraph-io/dgraph/graphql/schema" - "github.com/golang/glog" "github.com/pkg/errors" geom "github.com/twpayne/go-geom" @@ -39,6 +37,7 @@ import ( "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/algo" + gqlSchema "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/task" "github.com/dgraph-io/dgraph/types" @@ -287,21 +286,21 @@ const ( // fastJsonNode represents node of a tree, which is formed to convert a subgraph into json response // for a query. A fastJsonNode has following meta data: -// 1. Attr => predicate associated with this node. -// 2. ScalarVal => Any value associated with node, if it is a leaf node. -// 3. List => Stores boolean value, true if this node is part of list. -// 4. FacetsParent => Stores boolean value, true if this node is a facetsParent. facetsParent is -// node which is parent for facets values for a scalar list predicate. Eg: node "city|country" -// will have FacetsParent value as true. -// { -// "city": ["Bengaluru", "San Francisco"], -// "city|country": { -// "0": "india", -// "1": "US" -// } -// } -// 5. Children(Attrs) => List of all children. -// 6. Visited => Stores boolen values, true if node has been visited for fixing children's order. +// 1. Attr => predicate associated with this node. +// 2. ScalarVal => Any value associated with node, if it is a leaf node. +// 3. List => Stores boolean value, true if this node is part of list. +// 4. FacetsParent => Stores boolean value, true if this node is a facetsParent. facetsParent is +// node which is parent for facets values for a scalar list predicate. Eg: node "city|country" +// will have FacetsParent value as true. +// { +// "city": ["Bengaluru", "San Francisco"], +// "city|country": { +// "0": "india", +// "1": "US" +// } +// } +// 5. Children(Attrs) => List of all children. +// 6. Visited => Stores boolen values, true if node has been visited for fixing children's order. // // All of the data for fastJsonNode tree is stored in encoder to optimise memory usage. fastJsonNode // struct is pointer to node object. node object stores below information. diff --git a/query/outputnode_graphql.go b/query/outputnode_graphql.go index 5aa8541dc62..fe1db3f3fe9 100644 --- a/query/outputnode_graphql.go +++ b/query/outputnode_graphql.go @@ -689,21 +689,23 @@ func (genc *graphQLEncoder) processCustomFields(field gqlSchema.Field, n fastJso // resolveCustomFields resolves fields with custom directive. Here is the rough algorithm that it // follows. -// queryUser { -// name @custom -// age -// school { -// name -// children -// class @custom { -// name -// numChildren -// } -// } -// cars @custom { -// name -// } -// } +// +// queryUser { +// name @custom +// age +// school { +// name +// children +// class @custom { +// name +// numChildren +// } +// } +// cars @custom { +// name +// } +// } +// // For fields with @custom directive // 1. There would be one query sent to the remote endpoint. // 2. In the above example, to fetch class all the school ids would be aggregated across different @@ -734,14 +736,15 @@ func (genc *graphQLEncoder) resolveCustomFields(childFields []gqlSchema.Field, // resolveCustomField resolves the @custom childField by making an external HTTP request and then // updates the fastJson tree with results of that HTTP request. // It accepts the following arguments: -// - childField: the @custom field which needs to be resolved -// - parentNodeHeads: a list of head pointers to the parent nodes of childField -// - wg: a wait group to signal the calling goroutine when the execution of this goroutine is -// finished +// - childField: the @custom field which needs to be resolved +// - parentNodeHeads: a list of head pointers to the parent nodes of childField +// - wg: a wait group to signal the calling goroutine when the execution of this goroutine is +// finished +// // TODO: -// - benchmark concurrency for the worker goroutines: channels vs mutexes? -// https://medium.com/@_orcaman/when-too-much-concurrency-slows-you-down-golang-9c144ca305a -// - worry about path in errors and how to deal with them, specially during completion step +// - benchmark concurrency for the worker goroutines: channels vs mutexes? +// https://medium.com/@_orcaman/when-too-much-concurrency-slows-you-down-golang-9c144ca305a +// - worry about path in errors and how to deal with them, specially during completion step func (genc *graphQLEncoder) resolveCustomField(childField gqlSchema.Field, parentNodeHeads []fastJsonNode, wg *sync.WaitGroup) { defer wg.Done() // signal when this goroutine finishes execution @@ -1012,12 +1015,13 @@ func (genc *graphQLEncoder) resolveCustomField(childField gqlSchema.Field, // resolveNestedFields resolves fields which themselves don't have the @custom directive but their // children might. // -// queryUser { -// id -// classes { -// name @custom... -// } -// } +// queryUser { +// id +// classes { +// name @custom... +// } +// } +// // In the example above, resolveNestedFields would be called on classes field and parentNodeHeads // would be the list of head pointers for all the user fastJson nodes. func (genc *graphQLEncoder) resolveNestedFields(childField gqlSchema.Field, @@ -1060,32 +1064,38 @@ func (genc *graphQLEncoder) resolveNestedFields(childField gqlSchema.Field, // objects, each object having only one property. So we need to handle encoding root aggregate // queries accordingly. // Dgraph result: -// { -// "aggregateCountry": [ -// { -// "CountryAggregateResult.count": 3 -// }, { -// "CountryAggregateResult.nameMin": "US1" -// }, { -// "CountryAggregateResult.nameMax": "US2" -// } -// ] -// } +// +// { +// "aggregateCountry": [ +// { +// "CountryAggregateResult.count": 3 +// }, { +// "CountryAggregateResult.nameMin": "US1" +// }, { +// "CountryAggregateResult.nameMax": "US2" +// } +// ] +// } +// // GraphQL Result: -// { -// "aggregateCountry": { -// "count": 3, -// "nameMin": "US1", -// "nameMax": "US2" -// } -// } +// +// { +// "aggregateCountry": { +// "count": 3, +// "nameMin": "US1", +// "nameMax": "US2" +// } +// } +// // Note that there can't be the case when an aggregate property was requested in DQL and not // returned by Dgraph because aggregate properties are calculated using math functions which // always give some result. // But, auth queries may lead to generation of following DQL: -// query { -// aggregateCountry() -// } +// +// query { +// aggregateCountry() +// } +// // which doesn't request any aggregate properties. In this case the fastJson node won't have any // children and we just need to write null as the value of the query. func (genc *graphQLEncoder) completeRootAggregateQuery(fj fastJsonNode, query gqlSchema.Field, @@ -1133,25 +1143,28 @@ func (genc *graphQLEncoder) completeRootAggregateQuery(fj fastJsonNode, query gq // completeAggregateChildren build GraphQL JSON for aggregate fields at child levels. // Dgraph result: -// { -// "Country.statesAggregate": [ -// { -// "State.name": "Calgary", -// "dgraph.uid": "0x2712" -// } -// ], -// "StateAggregateResult.count_Country.statesAggregate": 1, -// "StateAggregateResult.nameMin_Country.statesAggregate": "Calgary", -// "StateAggregateResult.nameMax_Country.statesAggregate": "Calgary" -// } +// +// { +// "Country.statesAggregate": [ +// { +// "State.name": "Calgary", +// "dgraph.uid": "0x2712" +// } +// ], +// "StateAggregateResult.count_Country.statesAggregate": 1, +// "StateAggregateResult.nameMin_Country.statesAggregate": "Calgary", +// "StateAggregateResult.nameMax_Country.statesAggregate": "Calgary" +// } +// // GraphQL result: -// { -// "statesAggregate": { -// "count": 1, -// "nameMin": "Calgary", -// "nameMax": "Calgary" -// } -// } +// +// { +// "statesAggregate": { +// "count": 1, +// "nameMin": "Calgary", +// "nameMax": "Calgary" +// } +// } func (genc *graphQLEncoder) completeAggregateChildren(fj fastJsonNode, field gqlSchema.Field, fieldPath []interface{}, respIsNull bool) fastJsonNode { if !respIsNull { diff --git a/query/outputnode_test.go b/query/outputnode_test.go index 852f40f73a6..f8cee4b41ae 100644 --- a/query/outputnode_test.go +++ b/query/outputnode_test.go @@ -25,11 +25,12 @@ import ( "sync" "testing" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - "github.com/stretchr/testify/require" ) func TestEncodeMemory(t *testing.T) { diff --git a/query/outputrdf.go b/query/outputrdf.go index 4bf4a9e5d7f..8b5620ababd 100644 --- a/query/outputrdf.go +++ b/query/outputrdf.go @@ -21,11 +21,12 @@ import ( "fmt" "strconv" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/algo" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" ) // rdfBuilder is used to generate RDF from subgraph. diff --git a/query/query1_test.go b/query/query1_test.go index 9bee134870c..eb637eb1b2a 100644 --- a/query/query1_test.go +++ b/query/query1_test.go @@ -25,10 +25,11 @@ import ( "testing" "time" - "github.com/dgraph-io/dgo/v210/protos/api" "github.com/pkg/errors" "github.com/stretchr/testify/require" "google.golang.org/grpc/metadata" + + "github.com/dgraph-io/dgo/v210/protos/api" ) func TestSchemaBlock2(t *testing.T) { diff --git a/query/query3_test.go b/query/query3_test.go index fcab4b9d568..258660b9655 100644 --- a/query/query3_test.go +++ b/query/query3_test.go @@ -23,9 +23,10 @@ import ( "strings" "testing" - "github.com/dgraph-io/dgraph/testutil" "github.com/stretchr/testify/require" "google.golang.org/grpc/metadata" + + "github.com/dgraph-io/dgraph/testutil" ) func TestRecurseError(t *testing.T) { diff --git a/query/query4_test.go b/query/query4_test.go index fffcf330c28..d4530179bf7 100644 --- a/query/query4_test.go +++ b/query/query4_test.go @@ -22,10 +22,11 @@ import ( "fmt" "testing" - "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/dgraph/x" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgo/v210/protos/api" + "github.com/dgraph-io/dgraph/x" ) func TestBigMathValue(t *testing.T) { diff --git a/query/recurse.go b/query/recurse.go index 5fe7403768b..abfb0498267 100644 --- a/query/recurse.go +++ b/query/recurse.go @@ -21,9 +21,10 @@ import ( "fmt" "math" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/algo" "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" ) func (start *SubGraph) expandRecurse(ctx context.Context, maxDepth uint64) error { diff --git a/query/shortest.go b/query/shortest.go index c0f19cf3f90..f2e0d3aca63 100644 --- a/query/shortest.go +++ b/query/shortest.go @@ -22,12 +22,13 @@ import ( "math" "sync" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/algo" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/types/facets" "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" ) type pathInfo struct { @@ -438,7 +439,6 @@ func runKShortestPaths(ctx context.Context, sg *SubGraph) ([]*SubGraph, error) { // Djikstras algorithm pseudocode for reference. // -// // 1 function Dijkstra(Graph, source): // 2 dist[source] ← 0 // Initialization // 3 diff --git a/raftwal/log.go b/raftwal/log.go index b0917e2ca8d..415a93632ad 100644 --- a/raftwal/log.go +++ b/raftwal/log.go @@ -28,14 +28,15 @@ import ( "strings" "time" + "github.com/golang/glog" + "github.com/pkg/errors" + "go.etcd.io/etcd/raft/raftpb" + "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/badger/v3/y" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - "github.com/golang/glog" - "github.com/pkg/errors" - "go.etcd.io/etcd/raft/raftpb" ) // WAL is divided up into entryFiles. Each entry file stores maxNumEntries in diff --git a/raftwal/meta.go b/raftwal/meta.go index 04c3729be86..db970e3e949 100644 --- a/raftwal/meta.go +++ b/raftwal/meta.go @@ -22,12 +22,13 @@ import ( "os" "path/filepath" - "github.com/dgraph-io/dgraph/x" - "github.com/dgraph-io/ristretto/z" "github.com/golang/glog" "github.com/pkg/errors" "go.etcd.io/etcd/raft" "go.etcd.io/etcd/raft/raftpb" + + "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" ) type MetaInfo int diff --git a/raftwal/storage.go b/raftwal/storage.go index eaebaa2e1e9..d708d4e118b 100644 --- a/raftwal/storage.go +++ b/raftwal/storage.go @@ -20,12 +20,13 @@ import ( "math" "sync" - "github.com/dgraph-io/dgraph/x" "github.com/golang/glog" "github.com/pkg/errors" "go.etcd.io/etcd/raft" "go.etcd.io/etcd/raft/raftpb" "golang.org/x/net/trace" + + "github.com/dgraph-io/dgraph/x" ) // versionKey is hardcoded into the special key used to fetch the maximum version from the DB. diff --git a/raftwal/storage_test.go b/raftwal/storage_test.go index 4bd7386390d..697b37cd7d6 100644 --- a/raftwal/storage_test.go +++ b/raftwal/storage_test.go @@ -41,11 +41,12 @@ import ( "reflect" "testing" - "github.com/dgraph-io/dgraph/x" "github.com/stretchr/testify/require" "go.etcd.io/etcd/raft" "go.etcd.io/etcd/raft/raftpb" pb "go.etcd.io/etcd/raft/raftpb" + + "github.com/dgraph-io/dgraph/x" ) func TestStorageTerm(t *testing.T) { diff --git a/raftwal/wal.go b/raftwal/wal.go index ff0bf0f9ded..8367e2eabb8 100644 --- a/raftwal/wal.go +++ b/raftwal/wal.go @@ -20,13 +20,14 @@ import ( "bytes" "sort" - "github.com/dgraph-io/badger/v3/y" - "github.com/dgraph-io/dgraph/x" - "github.com/dgraph-io/ristretto/z" "github.com/golang/glog" "github.com/pkg/errors" "go.etcd.io/etcd/raft" "go.etcd.io/etcd/raft/raftpb" + + "github.com/dgraph-io/badger/v3/y" + "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" ) var errNotFound = errors.New("Unable to find raft entry") diff --git a/schema/parse.go b/schema/parse.go index 4777055e47c..e2fde4e84c3 100644 --- a/schema/parse.go +++ b/schema/parse.go @@ -21,14 +21,14 @@ import ( "strconv" "strings" + "github.com/golang/glog" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/lex" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/tok" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" - - "github.com/golang/glog" - "github.com/pkg/errors" ) // ParseBytes parses the byte array which holds the schema. We will reset diff --git a/schema/schema.go b/schema/schema.go index 328f471e4c7..d672ffe2054 100644 --- a/schema/schema.go +++ b/schema/schema.go @@ -23,17 +23,17 @@ import ( "math" "sync" + "github.com/golang/glog" + "github.com/golang/protobuf/proto" + "github.com/pkg/errors" + "golang.org/x/net/trace" + "github.com/dgraph-io/badger/v3" badgerpb "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/tok" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" - - "github.com/golang/glog" - "github.com/golang/protobuf/proto" - "github.com/pkg/errors" - "golang.org/x/net/trace" ) var ( diff --git a/systest/1million/1million_test.go b/systest/1million/1million_test.go index 7e090649597..fe37d6be8e6 100644 --- a/systest/1million/1million_test.go +++ b/systest/1million/1million_test.go @@ -25,9 +25,10 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" - "github.com/stretchr/testify/require" ) var tc = []struct { diff --git a/systest/21million/bulk/run_test.go b/systest/21million/bulk/run_test.go index 983abaef245..7cdf8c8edf0 100644 --- a/systest/21million/bulk/run_test.go +++ b/systest/21million/bulk/run_test.go @@ -19,11 +19,10 @@ package bulk import ( "os" "path/filepath" + "testing" "github.com/dgraph-io/dgraph/systest/21million/common" "github.com/dgraph-io/dgraph/testutil" - - "testing" ) func TestQueries(t *testing.T) { diff --git a/systest/21million/live/run_test.go b/systest/21million/live/run_test.go index 4fdf78d713a..37ee5dfcf56 100644 --- a/systest/21million/live/run_test.go +++ b/systest/21million/live/run_test.go @@ -19,12 +19,10 @@ package bulk import ( "os" "path/filepath" - - "github.com/dgraph-io/dgraph/testutil" + "testing" "github.com/dgraph-io/dgraph/systest/21million/common" - - "testing" + "github.com/dgraph-io/dgraph/testutil" ) func TestQueries(t *testing.T) { diff --git a/systest/acl/restore/acl_restore_test.go b/systest/acl/restore/acl_restore_test.go index 8c1a2078bcc..e4caf4fdbdb 100644 --- a/systest/acl/restore/acl_restore_test.go +++ b/systest/acl/restore/acl_restore_test.go @@ -10,12 +10,13 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "google.golang.org/grpc" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/graphql/e2e/common" "github.com/dgraph-io/dgraph/testutil" - "github.com/stretchr/testify/require" - "google.golang.org/grpc" ) // disableDraining disables draining mode before each test for increased reliability. diff --git a/systest/audit/audit_test.go b/systest/audit/audit_test.go index d2f832a5d45..bb2df7606ba 100644 --- a/systest/audit/audit_test.go +++ b/systest/audit/audit_test.go @@ -25,8 +25,9 @@ import ( "path/filepath" "testing" - "github.com/dgraph-io/dgraph/testutil" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/testutil" ) func TestZeroAudit(t *testing.T) { diff --git a/systest/backup/common/utils.go b/systest/backup/common/utils.go index 866a1a7ae8f..0eb9c39a23e 100644 --- a/systest/backup/common/utils.go +++ b/systest/backup/common/utils.go @@ -20,9 +20,9 @@ import ( "os" "testing" - "github.com/dgraph-io/badger/v3/options" "github.com/stretchr/testify/require" + "github.com/dgraph-io/badger/v3/options" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/worker" ) diff --git a/systest/backup/encryption/backup_test.go b/systest/backup/encryption/backup_test.go index e9f0bce0412..d3b825002a9 100644 --- a/systest/backup/encryption/backup_test.go +++ b/systest/backup/encryption/backup_test.go @@ -28,16 +28,17 @@ import ( "testing" "time" + minio "github.com/minio/minio-go/v6" + "github.com/spf13/pflag" + "github.com/spf13/viper" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/badger/v3/options" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/ee" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" - minio "github.com/minio/minio-go/v6" - "github.com/spf13/pflag" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" ) var ( diff --git a/systest/backup/filesystem/backup_test.go b/systest/backup/filesystem/backup_test.go index a567cf5ac32..3da1a5080dd 100644 --- a/systest/backup/filesystem/backup_test.go +++ b/systest/backup/filesystem/backup_test.go @@ -28,14 +28,13 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "google.golang.org/grpc" "google.golang.org/grpc/credentials" "github.com/dgraph-io/badger/v3/options" "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/stretchr/testify/require" - "google.golang.org/grpc" - "github.com/dgraph-io/dgraph/systest/backup/common" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/worker" diff --git a/systest/backup/minio-large/backup_test.go b/systest/backup/minio-large/backup_test.go index e2eea45b6ac..c9a287297bd 100644 --- a/systest/backup/minio-large/backup_test.go +++ b/systest/backup/minio-large/backup_test.go @@ -26,15 +26,14 @@ import ( "testing" "time" + minio "github.com/minio/minio-go/v6" + "github.com/stretchr/testify/require" + "google.golang.org/grpc" "google.golang.org/grpc/credentials" "github.com/dgraph-io/badger/v3/options" "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" - minio "github.com/minio/minio-go/v6" - "github.com/stretchr/testify/require" - "google.golang.org/grpc" - "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" diff --git a/systest/backup/minio/backup_test.go b/systest/backup/minio/backup_test.go index fdedc7c6573..a8c05bdbdc6 100644 --- a/systest/backup/minio/backup_test.go +++ b/systest/backup/minio/backup_test.go @@ -28,15 +28,14 @@ import ( "testing" "time" + minio "github.com/minio/minio-go/v6" + "github.com/stretchr/testify/require" + "google.golang.org/grpc" "google.golang.org/grpc/credentials" "github.com/dgraph-io/badger/v3/options" "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" - minio "github.com/minio/minio-go/v6" - "github.com/stretchr/testify/require" - "google.golang.org/grpc" - "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" diff --git a/systest/backup/multi-tenancy/backup_test.go b/systest/backup/multi-tenancy/backup_test.go index a17d769be9e..d38b9aa35f4 100644 --- a/systest/backup/multi-tenancy/backup_test.go +++ b/systest/backup/multi-tenancy/backup_test.go @@ -22,10 +22,10 @@ import ( "strings" "testing" - "github.com/dgraph-io/dgo/v210" - "github.com/dgraph-io/dgo/v210/protos/api" "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v210" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/systest/backup/common" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" diff --git a/systest/bgindex/count_test.go b/systest/bgindex/count_test.go index abc8d8883aa..a58f5db9939 100644 --- a/systest/bgindex/count_test.go +++ b/systest/bgindex/count_test.go @@ -31,13 +31,13 @@ import ( "testing" "time" - "github.com/dgraph-io/dgraph/x" "github.com/stretchr/testify/require" "github.com/dgraph-io/badger/v3/y" "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" + "github.com/dgraph-io/dgraph/x" ) func TestCountIndex(t *testing.T) { diff --git a/systest/bgindex/parallel_test.go b/systest/bgindex/parallel_test.go index 29c52d491f9..bb5cb2228fe 100644 --- a/systest/bgindex/parallel_test.go +++ b/systest/bgindex/parallel_test.go @@ -27,13 +27,13 @@ import ( "testing" "time" - "github.com/dgraph-io/dgraph/x" "github.com/stretchr/testify/require" "github.com/dgraph-io/badger/v3/y" "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" + "github.com/dgraph-io/dgraph/x" ) var ( diff --git a/systest/bgindex/reverse_test.go b/systest/bgindex/reverse_test.go index ed5349ede0a..cc3a0e3e803 100644 --- a/systest/bgindex/reverse_test.go +++ b/systest/bgindex/reverse_test.go @@ -30,12 +30,12 @@ import ( "testing" "time" - "github.com/dgraph-io/dgraph/x" "github.com/stretchr/testify/require" "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" + "github.com/dgraph-io/dgraph/x" ) func TestReverseIndex(t *testing.T) { diff --git a/systest/bgindex/string_test.go b/systest/bgindex/string_test.go index 4356cae8a01..581c6b1d4ba 100644 --- a/systest/bgindex/string_test.go +++ b/systest/bgindex/string_test.go @@ -30,13 +30,13 @@ import ( "testing" "time" - "github.com/dgraph-io/dgraph/x" "github.com/stretchr/testify/require" "github.com/dgraph-io/badger/v3/y" "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" + "github.com/dgraph-io/dgraph/x" ) func TestStringIndex(t *testing.T) { diff --git a/systest/bulk_live/common/bulk_live_cases.go b/systest/bulk_live/common/bulk_live_cases.go index 0695052db8a..8e55b55c2bc 100644 --- a/systest/bulk_live/common/bulk_live_cases.go +++ b/systest/bulk_live/common/bulk_live_cases.go @@ -31,12 +31,12 @@ import ( "strings" "testing" - "github.com/dgraph-io/dgraph/testutil" "github.com/golang/glog" "github.com/pkg/errors" + "github.com/stretchr/testify/require" "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgraph/testutil" ) // TODO: This test was used just to make sure some really basic examples work. diff --git a/systest/bulk_live/common/bulk_live_fixture.go b/systest/bulk_live/common/bulk_live_fixture.go index 86b6584c196..ee638597bc8 100644 --- a/systest/bulk_live/common/bulk_live_fixture.go +++ b/systest/bulk_live/common/bulk_live_fixture.go @@ -25,11 +25,11 @@ import ( "testing" "time" - "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/dgraph/testutil" - "github.com/minio/minio-go/v6" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgo/v210/protos/api" + "github.com/dgraph-io/dgraph/testutil" ) var rootDir = "./data" diff --git a/systest/cdc/cdc_test.go b/systest/cdc/cdc_test.go index 31a93b4d945..8c8918e76b7 100644 --- a/systest/cdc/cdc_test.go +++ b/systest/cdc/cdc_test.go @@ -26,9 +26,9 @@ import ( "testing" "time" - "github.com/dgraph-io/dgraph/testutil" - "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/testutil" ) func TestCDC(t *testing.T) { diff --git a/systest/export/export_test.go b/systest/export/export_test.go index af8b5004fcd..974658c711e 100644 --- a/systest/export/export_test.go +++ b/systest/export/export_test.go @@ -26,12 +26,12 @@ import ( "path/filepath" "testing" - "github.com/dgraph-io/dgo/v210" - "github.com/dgraph-io/dgo/v210/protos/api" minio "github.com/minio/minio-go/v6" "github.com/stretchr/testify/require" "google.golang.org/grpc" + "github.com/dgraph-io/dgo/v210" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" ) diff --git a/systest/group-delete/group_delete_test.go b/systest/group-delete/group_delete_test.go index d122dc149c0..ae09208dd25 100644 --- a/systest/group-delete/group_delete_test.go +++ b/systest/group-delete/group_delete_test.go @@ -31,11 +31,12 @@ import ( "testing" "time" + "github.com/pkg/errors" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" - "github.com/pkg/errors" - "github.com/stretchr/testify/require" ) func NodesSetup(t *testing.T, c *dgo.Dgraph) { diff --git a/systest/ldbc/ldbc_test.go b/systest/ldbc/ldbc_test.go index 91bf2ddfbac..891d1721b90 100644 --- a/systest/ldbc/ldbc_test.go +++ b/systest/ldbc/ldbc_test.go @@ -9,9 +9,10 @@ import ( "testing" "time" - "github.com/dgraph-io/dgraph/testutil" "github.com/stretchr/testify/require" "gopkg.in/yaml.v2" + + "github.com/dgraph-io/dgraph/testutil" ) type TestCases struct { diff --git a/systest/license/license_test.go b/systest/license/license_test.go index cea1b1596f1..f8bac056e89 100644 --- a/systest/license/license_test.go +++ b/systest/license/license_test.go @@ -23,8 +23,9 @@ import ( "net/http" "testing" - "github.com/dgraph-io/dgraph/testutil" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/testutil" ) var expiredKey = []byte(`-----BEGIN PGP MESSAGE----- diff --git a/systest/live_pw_test.go b/systest/live_pw_test.go index e48f6906deb..3458b2149b9 100644 --- a/systest/live_pw_test.go +++ b/systest/live_pw_test.go @@ -21,10 +21,11 @@ import ( "fmt" "testing" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" - "github.com/stretchr/testify/require" ) func TestLivePassword(t *testing.T) { diff --git a/systest/loader/loader_test.go b/systest/loader/loader_test.go index 0c0401b91b6..a129244869d 100644 --- a/systest/loader/loader_test.go +++ b/systest/loader/loader_test.go @@ -25,7 +25,6 @@ import ( "testing" "github.com/spf13/viper" - "github.com/stretchr/testify/require" "github.com/dgraph-io/dgo/v210/protos/api" diff --git a/systest/multi-tenancy/basic_test.go b/systest/multi-tenancy/basic_test.go index 62cc1344778..cda5eb1b273 100644 --- a/systest/multi-tenancy/basic_test.go +++ b/systest/multi-tenancy/basic_test.go @@ -26,6 +26,8 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/ee/acl" @@ -33,7 +35,6 @@ import ( "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" - "github.com/stretchr/testify/require" ) func prepare(t *testing.T) { diff --git a/systest/mutations_test.go b/systest/mutations_test.go index 7e6d1ecef22..5c4cddb529d 100644 --- a/systest/mutations_test.go +++ b/systest/mutations_test.go @@ -30,10 +30,11 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" - "github.com/stretchr/testify/require" ) // TestSystem uses the externally run Dgraph cluster for testing. Most other diff --git a/systest/online-restore/online_restore_test.go b/systest/online-restore/online_restore_test.go index 957b3f4fe29..42a2426619f 100644 --- a/systest/online-restore/online_restore_test.go +++ b/systest/online-restore/online_restore_test.go @@ -28,14 +28,13 @@ import ( "testing" "time" - "google.golang.org/grpc/credentials" - - "github.com/dgraph-io/dgo/v210" - "github.com/dgraph-io/dgo/v210/protos/api" "github.com/graph-gophers/graphql-go/errors" "github.com/stretchr/testify/require" "google.golang.org/grpc" + "google.golang.org/grpc/credentials" + "github.com/dgraph-io/dgo/v210" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/chunker" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" diff --git a/systest/posting-list-benchmark/main.go b/systest/posting-list-benchmark/main.go index 0d5ef48f8a2..2a10565ae69 100644 --- a/systest/posting-list-benchmark/main.go +++ b/systest/posting-list-benchmark/main.go @@ -24,11 +24,12 @@ import ( "strings" "time" + "github.com/spf13/cobra" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" - "github.com/spf13/cobra" ) type flagOptions struct { diff --git a/systest/queries_test.go b/systest/queries_test.go index d974e559bb6..c8dc3d9d6c3 100644 --- a/systest/queries_test.go +++ b/systest/queries_test.go @@ -25,10 +25,11 @@ import ( "net/http" "testing" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" - "github.com/stretchr/testify/require" ) func TestQuery(t *testing.T) { diff --git a/t/t.go b/t/t.go index b82216b1aeb..b0b98a96115 100644 --- a/t/t.go +++ b/t/t.go @@ -37,14 +37,15 @@ import ( "syscall" "time" - "github.com/dgraph-io/dgraph/testutil" - "github.com/dgraph-io/dgraph/x" - "github.com/dgraph-io/ristretto/z" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/client" "github.com/spf13/pflag" "golang.org/x/tools/go/packages" + + "github.com/dgraph-io/dgraph/testutil" + "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" ) var ( diff --git a/telemetry/telemetry.go b/telemetry/telemetry.go index 6af383bba59..e25c07ac21b 100644 --- a/telemetry/telemetry.go +++ b/telemetry/telemetry.go @@ -24,11 +24,12 @@ import ( "runtime" "time" + "github.com/golang/glog" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" - "github.com/pkg/errors" ) // Telemetry holds information about the state of the zero and alpha server. diff --git a/testutil/backup.go b/testutil/backup.go index 7151f59d37b..f5655924b7d 100644 --- a/testutil/backup.go +++ b/testutil/backup.go @@ -26,6 +26,10 @@ import ( "testing" "time" + "github.com/spf13/pflag" + "github.com/spf13/viper" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgraph/ee" @@ -33,10 +37,6 @@ import ( "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" - - "github.com/spf13/pflag" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" ) // KeyFile is set to the path of the file containing the key. Used for testing purposes only. diff --git a/testutil/bulk.go b/testutil/bulk.go index 25f938128a1..de5c9d809ad 100644 --- a/testutil/bulk.go +++ b/testutil/bulk.go @@ -25,8 +25,9 @@ import ( "os/exec" "strconv" - "github.com/dgraph-io/dgraph/x" "github.com/pkg/errors" + + "github.com/dgraph-io/dgraph/x" ) type LiveOpts struct { diff --git a/testutil/client.go b/testutil/client.go index e916056ff7e..8c09ab23c3d 100644 --- a/testutil/client.go +++ b/testutil/client.go @@ -32,15 +32,16 @@ import ( "testing" "time" - "github.com/dgraph-io/dgo/v210" - "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/dgraph/dql" - "github.com/dgraph-io/dgraph/x" "github.com/pkg/errors" "github.com/spf13/viper" "github.com/stretchr/testify/require" "google.golang.org/grpc" "google.golang.org/grpc/credentials" + + "github.com/dgraph-io/dgo/v210" + "github.com/dgraph-io/dgo/v210/protos/api" + "github.com/dgraph-io/dgraph/dql" + "github.com/dgraph-io/dgraph/x" ) // socket addr = IP address and port number diff --git a/testutil/docker.go b/testutil/docker.go index 33ea89689e6..837b02f425f 100644 --- a/testutil/docker.go +++ b/testutil/docker.go @@ -29,11 +29,12 @@ import ( "strings" "time" - "github.com/dgraph-io/dgraph/x" "github.com/docker/docker/api/types" "github.com/docker/docker/client" "github.com/golang/glog" "golang.org/x/net/context" + + "github.com/dgraph-io/dgraph/x" ) const ( diff --git a/testutil/graphql.go b/testutil/graphql.go index 43e7ea32df9..7ea4f20a352 100644 --- a/testutil/graphql.go +++ b/testutil/graphql.go @@ -27,14 +27,12 @@ import ( "testing" "time" - "github.com/pkg/errors" - "github.com/dgrijalva/jwt-go/v4" + "github.com/pkg/errors" + "github.com/stretchr/testify/require" "google.golang.org/grpc/metadata" "github.com/dgraph-io/dgraph/x" - - "github.com/stretchr/testify/require" ) const ExportRequest = `mutation { diff --git a/testutil/multi_tenancy.go b/testutil/multi_tenancy.go index 496ca1bb17e..fa8a04ef1c1 100644 --- a/testutil/multi_tenancy.go +++ b/testutil/multi_tenancy.go @@ -25,12 +25,12 @@ import ( "time" "github.com/golang/glog" + "github.com/pkg/errors" + "github.com/stretchr/testify/require" "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" - "github.com/stretchr/testify/require" ) type Rule struct { diff --git a/testutil/schema.go b/testutil/schema.go index 00ceb85a012..c19d2d75a01 100644 --- a/testutil/schema.go +++ b/testutil/schema.go @@ -21,8 +21,9 @@ import ( "fmt" "testing" - "github.com/dgraph-io/dgo/v210" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgo/v210" ) const ( @@ -87,10 +88,11 @@ func GetInternalTypes(excludeAclTypes bool) string { // GetFullSchemaJSON returns a string representation of the JSON object returned by the full // schema{} query. It uses the user provided predicates and types along with the initial internal // schema to generate the string. Example response looks like: -// { -// "schema": [ ... ], -// "types": [ ... ] -// } +// +// { +// "schema": [ ... ], +// "types": [ ... ] +// } func GetFullSchemaJSON(opts SchemaOptions) string { expectedPreds := GetInternalPreds(opts.ExcludeAclSchema) if len(opts.UserPreds) > 0 { @@ -112,12 +114,13 @@ func GetFullSchemaJSON(opts SchemaOptions) string { // GetFullSchemaHTTPResponse returns a string representation of the HTTP response returned by the // full schema{} query. It uses the user provided predicates and types along with the initial // internal schema to generate the string. Example response looks like: -// { -// "data": { -// "schema": [ ... ], -// "types": [ ... ] -// } -// } +// +// { +// "data": { +// "schema": [ ... ], +// "types": [ ... ] +// } +// } func GetFullSchemaHTTPResponse(opts SchemaOptions) string { return `{"data":` + GetFullSchemaJSON(opts) + `}` } diff --git a/testutil/utils.go b/testutil/utils.go index 29e954901e3..7bb925db22d 100644 --- a/testutil/utils.go +++ b/testutil/utils.go @@ -24,9 +24,10 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgraph/x" - "github.com/stretchr/testify/require" ) func GalaxySchemaKey(attr string) []byte { diff --git a/testutil/zero.go b/testutil/zero.go index c43c35b14fd..f7e0716b4ad 100644 --- a/testutil/zero.go +++ b/testutil/zero.go @@ -24,10 +24,11 @@ import ( "net/http" "strings" - "github.com/dgraph-io/dgo/v210" - "github.com/dgraph-io/dgo/v210/protos/api" "github.com/pkg/errors" "google.golang.org/grpc" + + "github.com/dgraph-io/dgo/v210" + "github.com/dgraph-io/dgo/v210/protos/api" ) type Member struct { diff --git a/tlstest/acl/acl_over_tls_test.go b/tlstest/acl/acl_over_tls_test.go index 1d4d5b1da75..6dfdaf2c929 100644 --- a/tlstest/acl/acl_over_tls_test.go +++ b/tlstest/acl/acl_over_tls_test.go @@ -6,11 +6,11 @@ import ( "testing" "time" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" - "github.com/spf13/viper" ) func TestLoginOverTLS(t *testing.T) { diff --git a/tlstest/certrequest/certrequest_test.go b/tlstest/certrequest/certrequest_test.go index 4a65264689d..bc8217e1c9f 100644 --- a/tlstest/certrequest/certrequest_test.go +++ b/tlstest/certrequest/certrequest_test.go @@ -5,10 +5,11 @@ import ( "fmt" "testing" - "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/dgraph/testutil" "github.com/spf13/viper" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgo/v210/protos/api" + "github.com/dgraph-io/dgraph/testutil" ) func TestAccessOverPlaintext(t *testing.T) { diff --git a/tlstest/certrequireandverify/certrequireandverify_test.go b/tlstest/certrequireandverify/certrequireandverify_test.go index 6a8dda06c87..20bbeecd1b1 100644 --- a/tlstest/certrequireandverify/certrequireandverify_test.go +++ b/tlstest/certrequireandverify/certrequireandverify_test.go @@ -11,10 +11,11 @@ import ( "testing" "time" - "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/dgraph/testutil" "github.com/spf13/viper" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgo/v210/protos/api" + "github.com/dgraph-io/dgraph/testutil" ) func TestAccessWithoutClientCert(t *testing.T) { diff --git a/tlstest/certverifyifgiven/certverifyifgiven_test.go b/tlstest/certverifyifgiven/certverifyifgiven_test.go index acc9d535c34..b8af41f6e26 100644 --- a/tlstest/certverifyifgiven/certverifyifgiven_test.go +++ b/tlstest/certverifyifgiven/certverifyifgiven_test.go @@ -5,10 +5,11 @@ import ( "fmt" "testing" - "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/dgraph/testutil" "github.com/spf13/viper" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgo/v210/protos/api" + "github.com/dgraph-io/dgraph/testutil" ) func TestAccessWithoutClientCert(t *testing.T) { diff --git a/tlstest/mtls_internal/ha_6_node/ha_test.go b/tlstest/mtls_internal/ha_6_node/ha_test.go index 59e10840b9e..77fc2296b02 100644 --- a/tlstest/mtls_internal/ha_6_node/ha_test.go +++ b/tlstest/mtls_internal/ha_6_node/ha_test.go @@ -5,13 +5,14 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" - "github.com/stretchr/testify/require" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials" ) func runTests(t *testing.T, client *dgo.Dgraph) { diff --git a/tlstest/mtls_internal/multi_group/multi_group_test.go b/tlstest/mtls_internal/multi_group/multi_group_test.go index 289b316f3a9..d815731663c 100644 --- a/tlstest/mtls_internal/multi_group/multi_group_test.go +++ b/tlstest/mtls_internal/multi_group/multi_group_test.go @@ -5,13 +5,14 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" - "github.com/stretchr/testify/require" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials" ) func runTests(t *testing.T, client *dgo.Dgraph) { diff --git a/tlstest/mtls_internal/single_node/single_node_test.go b/tlstest/mtls_internal/single_node/single_node_test.go index 53fb4921acd..f20b2192d13 100644 --- a/tlstest/mtls_internal/single_node/single_node_test.go +++ b/tlstest/mtls_internal/single_node/single_node_test.go @@ -5,13 +5,14 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" - "github.com/stretchr/testify/require" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials" ) func runTests(t *testing.T, client *dgo.Dgraph) { diff --git a/tlstest/zero_https/all_routes_tls/all_routes_tls_test.go b/tlstest/zero_https/all_routes_tls/all_routes_tls_test.go index a67f0dcfe9d..2d64bd106be 100644 --- a/tlstest/zero_https/all_routes_tls/all_routes_tls_test.go +++ b/tlstest/zero_https/all_routes_tls/all_routes_tls_test.go @@ -9,9 +9,10 @@ import ( "testing" "time" - "github.com/dgraph-io/dgraph/testutil" "github.com/pkg/errors" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/testutil" ) type testCase struct { diff --git a/tlstest/zero_https/no_tls/no_tls_test.go b/tlstest/zero_https/no_tls/no_tls_test.go index 6f6553a2224..3bcfcff5ba4 100644 --- a/tlstest/zero_https/no_tls/no_tls_test.go +++ b/tlstest/zero_https/no_tls/no_tls_test.go @@ -7,8 +7,9 @@ import ( "testing" "time" - "github.com/dgraph-io/dgraph/testutil" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/testutil" ) type testCase struct { diff --git a/tok/bleve.go b/tok/bleve.go index 2cdc53502ad..cc51d483b24 100644 --- a/tok/bleve.go +++ b/tok/bleve.go @@ -17,14 +17,14 @@ package tok import ( - "github.com/dgraph-io/dgraph/x" - "github.com/blevesearch/bleve/analysis" "github.com/blevesearch/bleve/analysis/analyzer/custom" "github.com/blevesearch/bleve/analysis/token/lowercase" "github.com/blevesearch/bleve/analysis/token/unicodenorm" "github.com/blevesearch/bleve/analysis/tokenizer/unicode" "github.com/blevesearch/bleve/registry" + + "github.com/dgraph-io/dgraph/x" ) const unicodenormName = "unicodenorm_nfkc" diff --git a/tok/tok.go b/tok/tok.go index ce689c9d609..550918da7b9 100644 --- a/tok/tok.go +++ b/tok/tok.go @@ -23,13 +23,13 @@ import ( "time" "github.com/golang/glog" + "github.com/pkg/errors" geom "github.com/twpayne/go-geom" "golang.org/x/crypto/blake2b" "golang.org/x/text/collate" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" ) // Tokenizer identifiers are unique and can't be reused. diff --git a/tools.go b/tools.go index 23e3b3b3f63..35bffb30497 100644 --- a/tools.go +++ b/tools.go @@ -14,6 +14,7 @@ // limitations under the License. // +//go:build tools // +build tools package tools diff --git a/types/facets/utils.go b/types/facets/utils.go index 57b3f0cc8c6..23f602f7129 100644 --- a/types/facets/utils.go +++ b/types/facets/utils.go @@ -22,11 +22,12 @@ import ( "strconv" "unicode" + "github.com/pkg/errors" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/tok" "github.com/dgraph-io/dgraph/types" - "github.com/pkg/errors" ) // SortAndValidate sorts And validates the facets. diff --git a/types/geofilter.go b/types/geofilter.go index 4ba8e91124a..9185405e0b5 100644 --- a/types/geofilter.go +++ b/types/geofilter.go @@ -22,12 +22,12 @@ import ( "strings" "github.com/golang/geo/s2" + "github.com/pkg/errors" geom "github.com/twpayne/go-geom" + "github.com/twpayne/go-geom/xy" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" - "github.com/twpayne/go-geom/xy" ) // QueryType indicates the type of geo query. diff --git a/types/password.go b/types/password.go index 8d687bac0c8..9b615eb7593 100644 --- a/types/password.go +++ b/types/password.go @@ -17,9 +17,8 @@ package types import ( - "golang.org/x/crypto/bcrypt" - "github.com/pkg/errors" + "golang.org/x/crypto/bcrypt" ) const ( diff --git a/types/s2.go b/types/s2.go index 87fdb3e4868..21b94c188a9 100644 --- a/types/s2.go +++ b/types/s2.go @@ -19,11 +19,12 @@ package types import ( "encoding/json" - "github.com/dgraph-io/dgraph/x" "github.com/golang/geo/s2" "github.com/pkg/errors" geom "github.com/twpayne/go-geom" "github.com/twpayne/go-geom/encoding/geojson" + + "github.com/dgraph-io/dgraph/x" ) func edgesCrossPoints(l *s2.Loop, pts []s2.Point) bool { diff --git a/types/s2index.go b/types/s2index.go index add1e92522d..d43c37fda4f 100644 --- a/types/s2index.go +++ b/types/s2index.go @@ -20,10 +20,10 @@ import ( "log" "github.com/golang/geo/s2" + "github.com/pkg/errors" geom "github.com/twpayne/go-geom" "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" ) func parentCoverTokens(parents s2.CellUnion, cover s2.CellUnion) []string { diff --git a/types/scalar_types.go b/types/scalar_types.go index 4d5b0e73c23..3c76bc9e32f 100644 --- a/types/scalar_types.go +++ b/types/scalar_types.go @@ -19,8 +19,9 @@ package types import ( "time" - "github.com/dgraph-io/dgraph/protos/pb" geom "github.com/twpayne/go-geom" + + "github.com/dgraph-io/dgraph/protos/pb" ) const nanoSecondsInSec = 1000000000 diff --git a/types/sort.go b/types/sort.go index d550b535017..f6a75c1d039 100644 --- a/types/sort.go +++ b/types/sort.go @@ -20,11 +20,12 @@ import ( "sort" "time" - "github.com/dgraph-io/dgraph/protos/pb" - "github.com/dgraph-io/dgraph/x" "github.com/pkg/errors" "golang.org/x/text/collate" "golang.org/x/text/language" + + "github.com/dgraph-io/dgraph/protos/pb" + "github.com/dgraph-io/dgraph/x" ) type sortBase struct { diff --git a/types/sort_test.go b/types/sort_test.go index 41d9801e2cf..b1bb6329350 100644 --- a/types/sort_test.go +++ b/types/sort_test.go @@ -19,8 +19,9 @@ package types import ( "testing" - "github.com/dgraph-io/dgraph/protos/pb" "github.com/stretchr/testify/require" + + "github.com/dgraph-io/dgraph/protos/pb" ) func toString(t *testing.T, values [][]Val, vID TypeID) []string { diff --git a/upgrade/change_v21.03.0.go b/upgrade/change_v21.03.0.go index 6ca7c557e0c..997b0d81b53 100644 --- a/upgrade/change_v21.03.0.go +++ b/upgrade/change_v21.03.0.go @@ -22,6 +22,9 @@ import ( "net/http" "strconv" + "github.com/golang/glog" + "github.com/pkg/errors" + "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" @@ -29,8 +32,6 @@ import ( "github.com/dgraph-io/dgraph/posting" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" - "github.com/pkg/errors" ) const ( diff --git a/upgrade/doc.go b/upgrade/doc.go index 7dd25b286c0..f0567ce8247 100644 --- a/upgrade/doc.go +++ b/upgrade/doc.go @@ -24,16 +24,16 @@ // you really need to modify any existing files. // // When adding upgrade capability for a new dgraph release version, follow these steps: -// 1. Create a file named `change_.go`. For example: change_v20.07.0.go -// 2. For any change that needs to be introduced in that version, create a function of the form -// `func() error` that applies that change, in the newly created file. -// 3. Add that function to change_list.go inside the changes for the change set introduced in -// that version. Also add a short name and some meaningful description with it. +// 1. Create a file named `change_.go`. For example: change_v20.07.0.go +// 2. For any change that needs to be introduced in that version, create a function of the form +// `func() error` that applies that change, in the newly created file. +// 3. Add that function to change_list.go inside the changes for the change set introduced in +// that version. Also add a short name and some meaningful description with it. // // Points to keep in mind: -// 1. Upgrade is expected only for breaking changes which go in as part of the breaking releases. -// 2. Look at the upgrade algorithm in upgrade.go to understand how & when a change is applied. -// 3. There are many re-usable functions in utils.go for the upgrade process, look at them too. -// 4. Thoroughly test your upgrade to make sure that it works correctly while upgrading from -// previous versions to the new release version, as an upgrade is very critical process. +// 1. Upgrade is expected only for breaking changes which go in as part of the breaking releases. +// 2. Look at the upgrade algorithm in upgrade.go to understand how & when a change is applied. +// 3. There are many re-usable functions in utils.go for the upgrade process, look at them too. +// 4. Thoroughly test your upgrade to make sure that it works correctly while upgrading from +// previous versions to the new release version, as an upgrade is very critical process. package upgrade diff --git a/upgrade/upgrade.go b/upgrade/upgrade.go index 89bf6b1189f..4c964910c2c 100644 --- a/upgrade/upgrade.go +++ b/upgrade/upgrade.go @@ -24,8 +24,9 @@ import ( "strconv" "strings" - "github.com/dgraph-io/dgraph/x" "github.com/spf13/cobra" + + "github.com/dgraph-io/dgraph/x" ) var ( @@ -131,7 +132,7 @@ type changeSet struct { // changeList represents a list of changeSet, i.e., a list of all the changes that were ever // introduced since the beginning of Dgraph. -//The changeSets in this list are supposed to be in sorted order based on when they were introduced. +// The changeSets in this list are supposed to be in sorted order based on when they were introduced. type changeList []*changeSet type commandInput struct { @@ -219,14 +220,14 @@ func formatAsFlagRequiredError(flag string) error { // parseVersionFromString parses a version given as string to internal representation. // Some examples for input and output: -// 1. input : v1.2.2 -// output: &version{major: 1, minor: 2, patch: 2}, nil -// 2. input : v20.03.0-beta.20200320 -// output: &version{major: 20, minor: 3, patch: 0}, nil -// 3. input : 1.2.2 -// output: nil, error -// 4. input : v1.2.2s -// output: nil, error +// 1. input : v1.2.2 +// output: &version{major: 1, minor: 2, patch: 2}, nil +// 2. input : v20.03.0-beta.20200320 +// output: &version{major: 20, minor: 3, patch: 0}, nil +// 3. input : 1.2.2 +// output: nil, error +// 4. input : v1.2.2s +// output: nil, error func parseVersionFromString(v string) (*version, error) { v = strings.TrimSpace(v) if v == "" || v[:1] != "v" { diff --git a/upgrade/utils.go b/upgrade/utils.go index af7fd047568..357110812eb 100644 --- a/upgrade/utils.go +++ b/upgrade/utils.go @@ -26,11 +26,12 @@ import ( "strings" "time" + "github.com/pkg/errors" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/graphql/schema" "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" ) func hasAclCreds() bool { @@ -250,24 +251,29 @@ func alterWithClient(dg *dgo.Dgraph, operation *api.Operation) error { // will contain the new name for that predicate. Also, if some predicates need to be // removed from the type, then they can be supplied in predsToRemove. For example: // initialType: -// type Person { -// name -// age -// unnecessaryEdge -// } +// +// type Person { +// name +// age +// unnecessaryEdge +// } +// // also, -// newTypeName = "Human" -// newPredNames = { -// "age": "ageOnEarth' -// } -// predsToRemove = { -// "unnecessaryEdge": {} -// } +// +// newTypeName = "Human" +// newPredNames = { +// "age": "ageOnEarth' +// } +// predsToRemove = { +// "unnecessaryEdge": {} +// } +// // then returned type string will be: -// type Human { -// name -// ageOnEarth -// } +// +// type Human { +// name +// ageOnEarth +// } func getTypeSchemaString(newTypeName string, typeNode *schemaTypeNode, newPredNames map[string]string, predsToRemove map[string]struct{}) string { var builder strings.Builder diff --git a/worker/acl_cache.go b/worker/acl_cache.go index 5992a4859c4..21bbf2c6176 100644 --- a/worker/acl_cache.go +++ b/worker/acl_cache.go @@ -16,10 +16,10 @@ package worker import ( "sync" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/ee/acl" "github.com/dgraph-io/dgraph/x" - - "github.com/pkg/errors" ) // aclCache is the cache mapping group names to the corresponding group acls diff --git a/worker/acl_cache_test.go b/worker/acl_cache_test.go index ab3e543547a..c643489ef0f 100644 --- a/worker/acl_cache_test.go +++ b/worker/acl_cache_test.go @@ -16,10 +16,10 @@ package worker import ( "testing" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgraph/ee/acl" "github.com/dgraph-io/dgraph/x" - - "github.com/stretchr/testify/require" ) func TestAclCache(t *testing.T) { diff --git a/worker/backup.go b/worker/backup.go index c4f7cc13e57..b25af95302e 100644 --- a/worker/backup.go +++ b/worker/backup.go @@ -20,11 +20,11 @@ import ( "context" "math" + "github.com/pkg/errors" + "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" - - "github.com/pkg/errors" ) // predicateSet is a map whose keys are predicates. It is meant to be used as a set. diff --git a/worker/backup_ee.go b/worker/backup_ee.go index 2ddcd5c0010..9e74f9ab48d 100644 --- a/worker/backup_ee.go +++ b/worker/backup_ee.go @@ -25,6 +25,12 @@ import ( "sync" "time" + "github.com/golang/glog" + "github.com/golang/protobuf/proto" + "github.com/golang/snappy" + "github.com/pkg/errors" + ostats "go.opencensus.io/stats" + "github.com/dgraph-io/badger/v3" bpb "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/badger/v3/y" @@ -33,12 +39,6 @@ import ( "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - - "github.com/golang/glog" - "github.com/golang/protobuf/proto" - "github.com/golang/snappy" - "github.com/pkg/errors" - ostats "go.opencensus.io/stats" ) // Backup handles a request coming from another node. diff --git a/worker/backup_handler.go b/worker/backup_handler.go index 1d40de13d48..a0ed316cb8b 100644 --- a/worker/backup_handler.go +++ b/worker/backup_handler.go @@ -23,13 +23,13 @@ import ( "path/filepath" "time" - "github.com/dgraph-io/dgraph/protos/pb" - "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" "github.com/minio/minio-go/v6" "github.com/minio/minio-go/v6/pkg/credentials" "github.com/pkg/errors" + + "github.com/dgraph-io/dgraph/protos/pb" + "github.com/dgraph-io/dgraph/x" ) const ( diff --git a/worker/backup_manifest.go b/worker/backup_manifest.go index 482ae215a40..c8beaf5594a 100644 --- a/worker/backup_manifest.go +++ b/worker/backup_manifest.go @@ -20,10 +20,10 @@ import ( "sort" "strings" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" - - "github.com/pkg/errors" ) func verifyManifests(manifests []*Manifest) error { diff --git a/worker/backup_oss.go b/worker/backup_oss.go index 815632a241a..51bb405ba06 100644 --- a/worker/backup_oss.go +++ b/worker/backup_oss.go @@ -22,10 +22,10 @@ package worker import ( "context" + "github.com/golang/glog" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" - - "github.com/golang/glog" ) // Backup implements the Worker interface. diff --git a/worker/cdc.go b/worker/cdc.go index ab5fc279dd7..ac37542fd3b 100644 --- a/worker/cdc.go +++ b/worker/cdc.go @@ -1,3 +1,4 @@ +//go:build oss // +build oss /* diff --git a/worker/cdc_ee.go b/worker/cdc_ee.go index 57995eaf115..cc1c31f44b2 100644 --- a/worker/cdc_ee.go +++ b/worker/cdc_ee.go @@ -23,15 +23,15 @@ import ( "sync/atomic" "time" + "github.com/golang/glog" + "github.com/pkg/errors" + "go.etcd.io/etcd/raft/raftpb" + "github.com/dgraph-io/dgraph/posting" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - - "github.com/golang/glog" - "github.com/pkg/errors" - "go.etcd.io/etcd/raft/raftpb" ) const ( diff --git a/worker/draft.go b/worker/draft.go index 77e107d7550..4cf22765df4 100644 --- a/worker/draft.go +++ b/worker/draft.go @@ -28,6 +28,16 @@ import ( "sync/atomic" "time" + "github.com/dustin/go-humanize" + "github.com/golang/glog" + "github.com/pkg/errors" + "go.etcd.io/etcd/raft" + "go.etcd.io/etcd/raft/raftpb" + ostats "go.opencensus.io/stats" + "go.opencensus.io/tag" + otrace "go.opencensus.io/trace" + "golang.org/x/net/trace" + "github.com/dgraph-io/badger/v3" bpb "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/dgraph/conn" @@ -38,16 +48,6 @@ import ( "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - - "github.com/dustin/go-humanize" - "github.com/golang/glog" - "github.com/pkg/errors" - "go.etcd.io/etcd/raft" - "go.etcd.io/etcd/raft/raftpb" - ostats "go.opencensus.io/stats" - "go.opencensus.io/tag" - otrace "go.opencensus.io/trace" - "golang.org/x/net/trace" ) type operation struct { diff --git a/worker/draft_test.go b/worker/draft_test.go index c569e95a940..82a87be409d 100644 --- a/worker/draft_test.go +++ b/worker/draft_test.go @@ -21,13 +21,13 @@ import ( "os" "testing" + "github.com/stretchr/testify/require" + "go.etcd.io/etcd/raft/raftpb" + "github.com/dgraph-io/dgraph/posting" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/raftwal" "github.com/dgraph-io/dgraph/x" - - "github.com/stretchr/testify/require" - "go.etcd.io/etcd/raft/raftpb" ) func getEntryForMutation(index, startTs uint64) raftpb.Entry { diff --git a/worker/executor.go b/worker/executor.go index 99c82616171..8d318a618b5 100644 --- a/worker/executor.go +++ b/worker/executor.go @@ -25,6 +25,9 @@ import ( "sync" "sync/atomic" + "github.com/dgryski/go-farm" + "github.com/golang/glog" + "github.com/dgraph-io/badger/v3/y" "github.com/dgraph-io/dgraph/posting" "github.com/dgraph-io/dgraph/protos/pb" @@ -33,9 +36,6 @@ import ( "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - - "github.com/dgryski/go-farm" - "github.com/golang/glog" ) type subMutation struct { diff --git a/worker/export.go b/worker/export.go index 0788f3142b8..606f392725d 100644 --- a/worker/export.go +++ b/worker/export.go @@ -32,6 +32,10 @@ import ( "strings" "time" + "github.com/golang/glog" + "github.com/minio/minio-go/v6" + "github.com/pkg/errors" + "github.com/dgraph-io/badger/v3" bpb "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/dgo/v210/protos/api" @@ -42,10 +46,6 @@ import ( "github.com/dgraph-io/dgraph/types/facets" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - - "github.com/golang/glog" - "github.com/minio/minio-go/v6" - "github.com/pkg/errors" ) // DefaultExportFormat stores the name of the default format for exports. diff --git a/worker/export_test.go b/worker/export_test.go index a5af3fd8841..f7ba870d805 100644 --- a/worker/export_test.go +++ b/worker/export_test.go @@ -32,6 +32,9 @@ import ( "testing" "time" + "github.com/golang/protobuf/proto" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/chunker" "github.com/dgraph-io/dgraph/dql" @@ -43,9 +46,6 @@ import ( "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/types/facets" "github.com/dgraph-io/dgraph/x" - - "github.com/golang/protobuf/proto" - "github.com/stretchr/testify/require" ) const ( diff --git a/worker/graphql_schema.go b/worker/graphql_schema.go index 26439ede976..fc183cfc201 100644 --- a/worker/graphql_schema.go +++ b/worker/graphql_schema.go @@ -22,14 +22,14 @@ import ( "sync" "time" + "github.com/golang/glog" + "github.com/pkg/errors" + "google.golang.org/grpc/metadata" + "github.com/dgraph-io/dgraph/conn" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/x" - - "github.com/golang/glog" - "github.com/pkg/errors" - "google.golang.org/grpc/metadata" ) const ( diff --git a/worker/groups.go b/worker/groups.go index f11c15edd2b..ee123a5439d 100644 --- a/worker/groups.go +++ b/worker/groups.go @@ -25,6 +25,10 @@ import ( "sync/atomic" "time" + "github.com/golang/glog" + "github.com/golang/protobuf/proto" + "github.com/pkg/errors" + badgerpb "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/conn" @@ -34,10 +38,6 @@ import ( "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - - "github.com/golang/glog" - "github.com/golang/protobuf/proto" - "github.com/pkg/errors" ) type groupi struct { diff --git a/worker/match.go b/worker/match.go index f9b479dccfe..d72bc8e7851 100644 --- a/worker/match.go +++ b/worker/match.go @@ -82,8 +82,8 @@ func matchFuzzy(query, val string, max int) bool { // Returns the list of uids even if empty, or an error otherwise. func uidsForMatch(attr string, arg funcArgs) (*pb.List, error) { opts := posting.ListOptions{ - ReadTs: arg.q.ReadTs, - First: int(arg.q.First), + ReadTs: arg.q.ReadTs, + First: int(arg.q.First), AfterUid: arg.q.AfterUid, } uidsForNgram := func(ngram string) (*pb.List, error) { diff --git a/worker/multi_tenancy.go b/worker/multi_tenancy.go index e03a94544d2..c82d67a1ae3 100644 --- a/worker/multi_tenancy.go +++ b/worker/multi_tenancy.go @@ -1,3 +1,4 @@ +//go:build oss // +build oss /* diff --git a/worker/multi_tenancy_ee.go b/worker/multi_tenancy_ee.go index 8d07b669bc6..56867bc3141 100644 --- a/worker/multi_tenancy_ee.go +++ b/worker/multi_tenancy_ee.go @@ -1,3 +1,4 @@ +//go:build !oss // +build !oss /* @@ -16,12 +17,13 @@ import ( "context" "time" - "github.com/dgraph-io/dgraph/conn" - "github.com/dgraph-io/dgraph/protos/pb" - "github.com/dgraph-io/dgraph/x" "github.com/golang/glog" "github.com/pkg/errors" "golang.org/x/sync/errgroup" + + "github.com/dgraph-io/dgraph/conn" + "github.com/dgraph-io/dgraph/protos/pb" + "github.com/dgraph-io/dgraph/x" ) func (w *grpcWorker) DeleteNamespace(ctx context.Context, diff --git a/worker/mutation.go b/worker/mutation.go index 45a0e722ffb..53381f72f9c 100644 --- a/worker/mutation.go +++ b/worker/mutation.go @@ -24,16 +24,14 @@ import ( "sync/atomic" "time" - "github.com/dgraph-io/badger/v3/y" - "google.golang.org/grpc/metadata" - - ostats "go.opencensus.io/stats" - "github.com/golang/glog" "github.com/pkg/errors" + ostats "go.opencensus.io/stats" otrace "go.opencensus.io/trace" + "google.golang.org/grpc/metadata" "github.com/dgraph-io/badger/v3" + "github.com/dgraph-io/badger/v3/y" "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/conn" diff --git a/worker/online_restore.go b/worker/online_restore.go index b457cf9dbbb..6fe53921451 100644 --- a/worker/online_restore.go +++ b/worker/online_restore.go @@ -25,6 +25,12 @@ import ( "sync" "time" + "github.com/golang/glog" + "github.com/golang/protobuf/proto" + "github.com/pkg/errors" + "github.com/spf13/pflag" + "github.com/spf13/viper" + "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/badger/v3/options" "github.com/dgraph-io/dgraph/conn" @@ -33,12 +39,6 @@ import ( "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/x" - - "github.com/golang/glog" - "github.com/golang/protobuf/proto" - "github.com/pkg/errors" - "github.com/spf13/pflag" - "github.com/spf13/viper" ) const ( diff --git a/worker/online_restore_oss.go b/worker/online_restore_oss.go index 46b907feb36..47b8d5b475f 100644 --- a/worker/online_restore_oss.go +++ b/worker/online_restore_oss.go @@ -1,3 +1,4 @@ +//go:build oss // +build oss /* @@ -22,9 +23,10 @@ import ( "context" "sync" + "github.com/golang/glog" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" ) func ProcessRestoreRequest(ctx context.Context, req *pb.RestoreRequest, wg *sync.WaitGroup) error { diff --git a/worker/proposal.go b/worker/proposal.go index fea40a00ce1..96dfedf5738 100644 --- a/worker/proposal.go +++ b/worker/proposal.go @@ -23,17 +23,16 @@ import ( "sync/atomic" "time" + "github.com/pkg/errors" + ostats "go.opencensus.io/stats" + tag "go.opencensus.io/tag" + otrace "go.opencensus.io/trace" + "github.com/dgraph-io/dgraph/conn" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - - ostats "go.opencensus.io/stats" - tag "go.opencensus.io/tag" - otrace "go.opencensus.io/trace" - - "github.com/pkg/errors" ) const baseTimeout time.Duration = 4 * time.Second diff --git a/worker/queue.go b/worker/queue.go index aa91066a6a1..d662a068722 100644 --- a/worker/queue.go +++ b/worker/queue.go @@ -26,13 +26,14 @@ import ( "sync" "time" + "github.com/golang/glog" + "github.com/pkg/errors" + "github.com/dgraph-io/dgraph/conn" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/raftwal" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - "github.com/golang/glog" - "github.com/pkg/errors" ) // TaskStatusOverNetwork fetches the status of a task over the network. Alphas only know about the diff --git a/worker/restore_map.go b/worker/restore_map.go index 988832c2dfe..310f99e80bf 100644 --- a/worker/restore_map.go +++ b/worker/restore_map.go @@ -30,6 +30,12 @@ import ( "sync/atomic" "time" + "github.com/dustin/go-humanize" + "github.com/golang/glog" + "github.com/golang/snappy" + "github.com/pkg/errors" + "golang.org/x/sync/errgroup" + bpb "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/badger/v3/y" "github.com/dgraph-io/dgraph/codec" @@ -39,12 +45,6 @@ import ( "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - - "github.com/dustin/go-humanize" - "github.com/golang/glog" - "github.com/golang/snappy" - "github.com/pkg/errors" - "golang.org/x/sync/errgroup" ) type backupReader struct { diff --git a/worker/restore_reduce.go b/worker/restore_reduce.go index a99751a1770..c0a49c8a654 100644 --- a/worker/restore_reduce.go +++ b/worker/restore_reduce.go @@ -25,14 +25,14 @@ import ( "sync/atomic" "time" + "github.com/dustin/go-humanize" + "github.com/golang/glog" + "github.com/golang/snappy" + "github.com/dgraph-io/badger/v3/y" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - - "github.com/dustin/go-humanize" - "github.com/golang/glog" - "github.com/golang/snappy" ) const ( diff --git a/worker/server_state.go b/worker/server_state.go index 4c1c21a9543..a36fb4fec57 100644 --- a/worker/server_state.go +++ b/worker/server_state.go @@ -22,12 +22,13 @@ import ( "os" "time" + "github.com/golang/glog" + "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/raftwal" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - "github.com/golang/glog" ) const ( diff --git a/worker/sink_handler.go b/worker/sink_handler.go index 71ac15505c4..988ca3e5b2e 100644 --- a/worker/sink_handler.go +++ b/worker/sink_handler.go @@ -28,11 +28,10 @@ import ( "path/filepath" "strings" + "github.com/Shopify/sarama" "github.com/pkg/errors" "github.com/xdg/scram" - "github.com/Shopify/sarama" - "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" ) diff --git a/worker/snapshot.go b/worker/snapshot.go index 9340f7fbf12..5a51d0cef8b 100644 --- a/worker/snapshot.go +++ b/worker/snapshot.go @@ -21,7 +21,6 @@ import ( "sync/atomic" "time" - "github.com/dgraph-io/ristretto/z" "github.com/dustin/go-humanize" "github.com/golang/glog" "github.com/pkg/errors" @@ -33,6 +32,7 @@ import ( "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" ) const ( diff --git a/worker/snapshot_test.go b/worker/snapshot_test.go index e49dbdb09b5..3cac789f8cf 100644 --- a/worker/snapshot_test.go +++ b/worker/snapshot_test.go @@ -27,10 +27,11 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/testutil" - "github.com/stretchr/testify/require" ) func TestSnapshot(t *testing.T) { diff --git a/worker/sort.go b/worker/sort.go index 6392d51b9b7..b546bbfdd7e 100644 --- a/worker/sort.go +++ b/worker/sort.go @@ -23,11 +23,11 @@ import ( "strings" "time" - "github.com/dgraph-io/badger/v3" "github.com/golang/glog" "github.com/pkg/errors" otrace "go.opencensus.io/trace" + "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/dgraph/algo" "github.com/dgraph-io/dgraph/posting" "github.com/dgraph-io/dgraph/protos/pb" diff --git a/worker/stringfilter.go b/worker/stringfilter.go index d620f6b2ed0..e14b8305e72 100644 --- a/worker/stringfilter.go +++ b/worker/stringfilter.go @@ -19,11 +19,12 @@ package worker import ( "strings" + "github.com/golang/glog" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/tok" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" ) type matchFunc func(types.Val, *stringFilter) bool diff --git a/worker/task.go b/worker/task.go index 192cd920e3d..7067c4ca72e 100644 --- a/worker/task.go +++ b/worker/task.go @@ -24,6 +24,14 @@ import ( "strings" "time" + "github.com/golang/glog" + "github.com/golang/protobuf/proto" + cindex "github.com/google/codesearch/index" + cregexp "github.com/google/codesearch/regexp" + "github.com/pkg/errors" + otrace "go.opencensus.io/trace" + "golang.org/x/sync/errgroup" + "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/dgo/v210/protos/api" "github.com/dgraph-io/dgraph/algo" @@ -36,14 +44,6 @@ import ( "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/types/facets" "github.com/dgraph-io/dgraph/x" - "github.com/golang/glog" - otrace "go.opencensus.io/trace" - "golang.org/x/sync/errgroup" - - "github.com/golang/protobuf/proto" - cindex "github.com/google/codesearch/index" - cregexp "github.com/google/codesearch/regexp" - "github.com/pkg/errors" ) func invokeNetworkRequest(ctx context.Context, addr string, diff --git a/worker/trigram.go b/worker/trigram.go index c61c70def63..0ec26f40c56 100644 --- a/worker/trigram.go +++ b/worker/trigram.go @@ -35,8 +35,8 @@ func uidsForRegex(attr string, arg funcArgs, query *cindex.Query, intersect *pb.List) (*pb.List, error) { var results *pb.List opts := posting.ListOptions{ - ReadTs: arg.q.ReadTs, - First: int(arg.q.First), + ReadTs: arg.q.ReadTs, + First: int(arg.q.First), AfterUid: arg.q.AfterUid, } if intersect.Size() > 0 { diff --git a/worker/worker.go b/worker/worker.go index 6375b8b20d3..69dbeca7172 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -26,18 +26,18 @@ import ( "sync" "sync/atomic" + "github.com/golang/glog" + "github.com/pkg/errors" + "go.opencensus.io/plugin/ocgrpc" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials" + "github.com/dgraph-io/badger/v3" badgerpb "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/dgraph/conn" "github.com/dgraph-io/dgraph/posting" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" - "go.opencensus.io/plugin/ocgrpc" - - "github.com/golang/glog" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials" ) var ( diff --git a/worker/worker_test.go b/worker/worker_test.go index 566bf816eca..b84d5e9c068 100644 --- a/worker/worker_test.go +++ b/worker/worker_test.go @@ -31,7 +31,6 @@ import ( "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/dgo/v210" "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/dgraph/posting" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" diff --git a/worker/zero_proxy.go b/worker/zero_proxy.go index 16896b62725..03a416ff0e2 100644 --- a/worker/zero_proxy.go +++ b/worker/zero_proxy.go @@ -3,11 +3,12 @@ package worker import ( "context" + "github.com/pkg/errors" + "google.golang.org/grpc" + "github.com/dgraph-io/dgraph/conn" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" - "github.com/pkg/errors" - "google.golang.org/grpc" ) func forwardAssignUidsToZero(ctx context.Context, in *pb.Num) (*pb.AssignedIds, error) { diff --git a/x/config.go b/x/config.go index 2512ad5f82c..f42d6dcbde3 100644 --- a/x/config.go +++ b/x/config.go @@ -21,9 +21,10 @@ import ( "net" "time" + "github.com/spf13/viper" + "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/ristretto/z" - "github.com/spf13/viper" ) // Options stores the options for this package. diff --git a/x/debug.go b/x/debug.go index cfc50bb723b..5cd78e1b521 100644 --- a/x/debug.go +++ b/x/debug.go @@ -1,3 +1,4 @@ +//go:build debug // +build debug /* diff --git a/x/disk_metrics_linux.go b/x/disk_metrics_linux.go index fd9ead79d1a..36ad65b598f 100644 --- a/x/disk_metrics_linux.go +++ b/x/disk_metrics_linux.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package x @@ -9,10 +10,11 @@ import ( "syscall" "time" - "github.com/dgraph-io/ristretto/z" "github.com/golang/glog" "go.opencensus.io/stats" "go.opencensus.io/tag" + + "github.com/dgraph-io/ristretto/z" ) func MonitorDiskMetrics(dirTag string, dir string, lc *z.Closer) { diff --git a/x/disk_metrics_others.go b/x/disk_metrics_others.go index 04ab4ba8b40..0464be68fb5 100644 --- a/x/disk_metrics_others.go +++ b/x/disk_metrics_others.go @@ -1,10 +1,12 @@ +//go:build !linux // +build !linux package x import ( - "github.com/dgraph-io/ristretto/z" "github.com/golang/glog" + + "github.com/dgraph-io/ristretto/z" ) func MonitorDiskMetrics(_ string, _ string, lc *z.Closer) { diff --git a/x/flags.go b/x/flags.go index b3ba8d13aec..6509b1954f9 100644 --- a/x/flags.go +++ b/x/flags.go @@ -17,8 +17,9 @@ package x import ( - "github.com/dgraph-io/ristretto/z" "github.com/spf13/pflag" + + "github.com/dgraph-io/ristretto/z" ) const ( diff --git a/x/init.go b/x/init.go index c81f82e8fd7..d3b82951d50 100644 --- a/x/init.go +++ b/x/init.go @@ -25,8 +25,9 @@ import ( "runtime" "strings" - "github.com/dgraph-io/ristretto/z" "github.com/golang/glog" + + "github.com/dgraph-io/ristretto/z" ) var ( diff --git a/x/keys.go b/x/keys.go index 1b1bf078ba1..8ed78ab86ac 100644 --- a/x/keys.go +++ b/x/keys.go @@ -189,7 +189,8 @@ func TypeKey(attr string) []byte { // next byte: data type prefix (set to ByteData) // next eight bytes: value of uid // next eight bytes (optional): if the key corresponds to a split list, the startUid of -// the split stored in this key and the first byte will be sets to ByteSplit. +// +// the split stored in this key and the first byte will be sets to ByteSplit. func DataKey(attr string, uid uint64) []byte { prefixLen := 1 + 2 + len(attr) totalLen := prefixLen + 1 + 8 @@ -212,7 +213,8 @@ func DataKey(attr string, uid uint64) []byte { // next byte: data type prefix (set to ByteReverse) // next eight bytes: value of uid // next eight bytes (optional): if the key corresponds to a split list, the startUid of -// the split stored in this key. +// +// the split stored in this key. func ReverseKey(attr string, uid uint64) []byte { prefixLen := 1 + 2 + len(attr) totalLen := prefixLen + 1 + 8 @@ -235,7 +237,8 @@ func ReverseKey(attr string, uid uint64) []byte { // next byte: data type prefix (set to ByteIndex) // next len(term) bytes: value of term // next eight bytes (optional): if the key corresponds to a split list, the startUid of -// the split stored in this key. +// +// the split stored in this key. func IndexKey(attr, term string) []byte { prefixLen := 1 + 2 + len(attr) totalLen := prefixLen + 1 + len(term) @@ -710,9 +713,9 @@ func IsGraphqlReservedPredicate(pred string) bool { // actually defined internally or not. // // As an example, consider below predicates: -// 1. dgraph.type (reserved = true, pre_defined = true ) -// 2. dgraph.blah (reserved = true, pre_defined = false) -// 3. person.name (reserved = false, pre_defined = false) +// 1. dgraph.type (reserved = true, pre_defined = true ) +// 2. dgraph.blah (reserved = true, pre_defined = false) +// 3. person.name (reserved = false, pre_defined = false) func IsReservedPredicate(pred string) bool { return isReservedName(ParseAttr(pred)) } diff --git a/x/log_writer.go b/x/log_writer.go index b31c2740507..e31c32fbec9 100644 --- a/x/log_writer.go +++ b/x/log_writer.go @@ -32,9 +32,8 @@ import ( "sync" "time" - "github.com/dgraph-io/ristretto/z" - "github.com/dgraph-io/badger/v3/y" + "github.com/dgraph-io/ristretto/z" ) const ( diff --git a/x/metrics.go b/x/metrics.go index e49dacceb7e..702d486bd0e 100644 --- a/x/metrics.go +++ b/x/metrics.go @@ -33,8 +33,6 @@ import ( "contrib.go.opencensus.io/exporter/jaeger" oc_prom "contrib.go.opencensus.io/exporter/prometheus" datadog "github.com/DataDog/opencensus-go-exporter-datadog" - "github.com/dgraph-io/badger/v3" - "github.com/dgraph-io/ristretto/z" "github.com/dustin/go-humanize" "github.com/golang/glog" "github.com/prometheus/client_golang/prometheus" @@ -44,6 +42,9 @@ import ( "go.opencensus.io/stats/view" "go.opencensus.io/tag" "go.opencensus.io/trace" + + "github.com/dgraph-io/badger/v3" + "github.com/dgraph-io/ristretto/z" ) var ( diff --git a/x/nodebug.go b/x/nodebug.go index 21cd72aa613..99c7d752bf6 100644 --- a/x/nodebug.go +++ b/x/nodebug.go @@ -1,3 +1,4 @@ +//go:build !debug // +build !debug /* @@ -19,9 +20,8 @@ package x import ( - bpb "github.com/dgraph-io/badger/v3/pb" - "github.com/dgraph-io/badger/v3" + bpb "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/dgraph/protos/pb" ) diff --git a/x/server.go b/x/server.go index b4c651136ad..be361a956e0 100644 --- a/x/server.go +++ b/x/server.go @@ -10,9 +10,10 @@ import ( "strings" "time" - "github.com/dgraph-io/ristretto/z" "github.com/golang/glog" "github.com/soheilhy/cmux" + + "github.com/dgraph-io/ristretto/z" ) var ( diff --git a/x/tls_helper.go b/x/tls_helper.go index d713ccdcd0f..c8b18800a9e 100644 --- a/x/tls_helper.go +++ b/x/tls_helper.go @@ -22,10 +22,11 @@ import ( "io/ioutil" "strings" - "github.com/dgraph-io/ristretto/z" "github.com/pkg/errors" "github.com/spf13/pflag" "github.com/spf13/viper" + + "github.com/dgraph-io/ristretto/z" ) // TLSHelperConfig define params used to create a tls.Config diff --git a/x/ulimit_unix.go b/x/ulimit_unix.go index dcd5c672182..587d2e90278 100644 --- a/x/ulimit_unix.go +++ b/x/ulimit_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows /* diff --git a/x/ulimit_windows.go b/x/ulimit_windows.go index 6d09800f561..fbd8da112a0 100644 --- a/x/ulimit_windows.go +++ b/x/ulimit_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows /* diff --git a/x/x.go b/x/x.go index 6ab848d8aec..58408710ad3 100644 --- a/x/x.go +++ b/x/x.go @@ -39,18 +39,7 @@ import ( "syscall" "time" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/peer" - - "github.com/dgraph-io/badger/v3" - bo "github.com/dgraph-io/badger/v3/options" - "github.com/dgraph-io/badger/v3/pb" - badgerpb "github.com/dgraph-io/badger/v3/pb" - "github.com/dgraph-io/dgo/v210" - "github.com/dgraph-io/dgo/v210/protos/api" - "github.com/dgraph-io/ristretto/z" "github.com/dustin/go-humanize" - "github.com/golang/glog" "github.com/pkg/errors" "github.com/spf13/viper" @@ -58,10 +47,20 @@ import ( "go.opencensus.io/trace" "golang.org/x/crypto/ssh/terminal" "google.golang.org/grpc" + "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" "google.golang.org/grpc/encoding/gzip" "google.golang.org/grpc/metadata" + "google.golang.org/grpc/peer" "google.golang.org/grpc/status" + + "github.com/dgraph-io/badger/v3" + bo "github.com/dgraph-io/badger/v3/options" + "github.com/dgraph-io/badger/v3/pb" + badgerpb "github.com/dgraph-io/badger/v3/pb" + "github.com/dgraph-io/dgo/v210" + "github.com/dgraph-io/dgo/v210/protos/api" + "github.com/dgraph-io/ristretto/z" ) // Error constants representing different types of errors. diff --git a/xidmap/xidmap.go b/xidmap/xidmap.go index be41f6174db..1099587e9cf 100644 --- a/xidmap/xidmap.go +++ b/xidmap/xidmap.go @@ -27,6 +27,8 @@ import ( "sync/atomic" "time" + "github.com/dgryski/go-farm" + "github.com/golang/glog" "google.golang.org/grpc" "google.golang.org/grpc/metadata" @@ -35,8 +37,6 @@ import ( "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - "github.com/dgryski/go-farm" - "github.com/golang/glog" ) var maxLeaseRegex = regexp.MustCompile(`currMax:([0-9]+)`) diff --git a/xidmap/xidmap_test.go b/xidmap/xidmap_test.go index a2bdda71bde..3fdf019bc90 100644 --- a/xidmap/xidmap_test.go +++ b/xidmap/xidmap_test.go @@ -12,12 +12,13 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "google.golang.org/grpc" + "github.com/dgraph-io/badger/v3" "github.com/dgraph-io/dgraph/testutil" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/ristretto/z" - "github.com/stretchr/testify/require" - "google.golang.org/grpc" ) // Opens a badger db and runs a a test on it.