diff --git a/ee/backup/run.go b/ee/backup/run.go index 314e8afe67d..7e2be5c166a 100644 --- a/ee/backup/run.go +++ b/ee/backup/run.go @@ -257,7 +257,7 @@ func runExportBackup() error { glog.Infof("Created temporary map directory: %s\n", mapDir) // TODO: Can probably make this procesing concurrent. - for gid, _ := range latestManifest.Groups { + for gid := range latestManifest.Groups { glog.Infof("Exporting group: %d", gid) req := &pb.RestoreRequest{ GroupId: gid, diff --git a/graphql/e2e/common/error.go b/graphql/e2e/common/error.go index a271671887f..24827536c8a 100644 --- a/graphql/e2e/common/error.go +++ b/graphql/e2e/common/error.go @@ -95,10 +95,10 @@ func graphQLCompletionOn(t *testing.T) { require.NoError(t, err) require.Equal(t, 5, len(result.QueryCountry)) expected.QueryCountry = []*country{ - &country{Name: "Angola"}, - &country{Name: "Bangladesh"}, - &country{Name: "India"}, - &country{Name: "Mozambique"}, + {Name: "Angola"}, + {Name: "Bangladesh"}, + {Name: "India"}, + {Name: "Mozambique"}, nil, } @@ -269,8 +269,8 @@ func panicCatcher(t *testing.T) { // the http stack. tests := map[string]*GraphQLParams{ - "query": &GraphQLParams{Query: `query { queryCountry { name } }`}, - "mutation": &GraphQLParams{ + "query": {Query: `query { queryCountry { name } }`}, + "mutation": { Query: `mutation { addCountry(input: [{ name: "A Country" }]) { country { id } } }`, diff --git a/graphql/e2e/common/query.go b/graphql/e2e/common/query.go index 2c99cb7d111..2c0ab814f2c 100644 --- a/graphql/e2e/common/query.go +++ b/graphql/e2e/common/query.go @@ -161,10 +161,10 @@ func queryByTypeWithEncoding(t *testing.T, acceptGzip, gzipEncoding bool) { QueryCountry []*country } expected.QueryCountry = []*country{ - &country{Name: "Angola"}, - &country{Name: "Bangladesh"}, - &country{Name: "India"}, - &country{Name: "Mozambique"}, + {Name: "Angola"}, + {Name: "Bangladesh"}, + {Name: "India"}, + {Name: "Mozambique"}, } err := json.Unmarshal([]byte(gqlResponse.Data), &result) require.NoError(t, err) @@ -197,10 +197,10 @@ func uidAlias(t *testing.T) { QueryCountry []*countryUID } expected.QueryCountry = []*countryUID{ - &countryUID{UID: "Angola"}, - &countryUID{UID: "Bangladesh"}, - &countryUID{UID: "India"}, - &countryUID{UID: "Mozambique"}, + {UID: "Angola"}, + {UID: "Bangladesh"}, + {UID: "India"}, + {UID: "Mozambique"}, } err := json.Unmarshal([]byte(gqlResponse.Data), &result) require.NoError(t, err) @@ -226,10 +226,10 @@ func orderAtRoot(t *testing.T) { QueryCountry []*country } expected.QueryCountry = []*country{ - &country{Name: "Angola"}, - &country{Name: "Bangladesh"}, - &country{Name: "India"}, - &country{Name: "Mozambique"}, + {Name: "Angola"}, + {Name: "Bangladesh"}, + {Name: "India"}, + {Name: "Mozambique"}, } err := json.Unmarshal([]byte(gqlResponse.Data), &result) require.NoError(t, err) @@ -255,8 +255,8 @@ func pageAtRoot(t *testing.T) { QueryCountry []*country } expected.QueryCountry = []*country{ - &country{Name: "India"}, - &country{Name: "Bangladesh"}, + {Name: "India"}, + {Name: "Bangladesh"}, } err := json.Unmarshal([]byte(gqlResponse.Data), &result) require.NoError(t, err) @@ -269,8 +269,8 @@ func pageAtRoot(t *testing.T) { func regExp(t *testing.T) { queryCountryByRegExp(t, "/[Aa]ng/", []*country{ - &country{Name: "Angola"}, - &country{Name: "Bangladesh"}, + {Name: "Angola"}, + {Name: "Bangladesh"}, }) } @@ -300,7 +300,7 @@ func multipleSearchIndexes(t *testing.T) { } expected.QueryPost = []*post{ - &post{Title: "Introducing GraphQL in Dgraph"}, + {Title: "Introducing GraphQL in Dgraph"}, } err := json.Unmarshal([]byte(gqlResponse.Data), &result) require.NoError(t, err) diff --git a/graphql/e2e/custom_logic/cmd/main.go b/graphql/e2e/custom_logic/cmd/main.go index a639235a661..b44ac8c0e97 100644 --- a/graphql/e2e/custom_logic/cmd/main.go +++ b/graphql/e2e/custom_logic/cmd/main.go @@ -824,7 +824,7 @@ func deleteCommonHeaders(headers http.Header) { func carsHandlerWithHeaders(w http.ResponseWriter, r *http.Request) { deleteCommonHeaders(r.Header) if err := compareHeaders(map[string][]string{ - "Stripe-Api-Key": []string{"some-api-key"}, + "Stripe-Api-Key": {"some-api-key"}, }, r.Header); err != nil { check2(w.Write([]byte(err.Error()))) return @@ -835,7 +835,7 @@ func carsHandlerWithHeaders(w http.ResponseWriter, r *http.Request) { func userNameHandlerWithHeaders(w http.ResponseWriter, r *http.Request) { deleteCommonHeaders(r.Header) if err := compareHeaders(map[string][]string{ - "Github-Api-Token": []string{"some-api-token"}, + "Github-Api-Token": {"some-api-token"}, }, r.Header); err != nil { check2(w.Write([]byte(err.Error()))) return @@ -1037,7 +1037,7 @@ func (_ *query) Countries(ctx context.Context, args struct { Name string } }) []countryResolver { - return []countryResolver{countryResolver{&country{ + return []countryResolver{{&country{ Code: graphql.ID(args.Filter.Code), Name: args.Filter.Name, }}} @@ -1142,7 +1142,7 @@ func (r *classResolver) Name() string { func (_ *query) Class(ctx context.Context, args struct { Id string }) *[]*classResolver { - return &[]*classResolver{&classResolver{&class{ID: graphql.ID(args.Id)}}} + return &[]*classResolver{{&class{ID: graphql.ID(args.Id)}}} } func (_ *query) UserNames(ctx context.Context, args struct { @@ -1190,7 +1190,7 @@ func (_ *query) Classes(ctx context.Context, args struct { resolvers := make([]*[]*classResolver, 0, len(*args.Schools)) for _, user := range *args.Schools { resolvers = append(resolvers, &[]*classResolver{ - &classResolver{&class{ID: graphql.ID(user.Id)}}}) + {&class{ID: graphql.ID(user.Id)}}}) } return &resolvers } @@ -1264,10 +1264,10 @@ func gqlCarsWithErrorHandler(w http.ResponseWriter, r *http.Request) { "cars": output, }, "errors": []map[string]interface{}{ - map[string]interface{}{ + { "message": "error-1 from cars", }, - map[string]interface{}{ + { "message": "error-2 from cars", }, }, diff --git a/graphql/e2e/custom_logic/custom_logic_test.go b/graphql/e2e/custom_logic/custom_logic_test.go index b1b28d83190..9c72c6c608b 100644 --- a/graphql/e2e/custom_logic/custom_logic_test.go +++ b/graphql/e2e/custom_logic/custom_logic_test.go @@ -200,9 +200,9 @@ func TestCustomQueryShouldForwardHeaders(t *testing.T) { params := &common.GraphQLParams{ Query: query, Headers: map[string][]string{ - "X-App-Token": []string{"app-token"}, - "X-User-Id": []string{"123"}, - "Random-header": []string{"random"}, + "X-App-Token": {"app-token"}, + "X-User-Id": {"123"}, + "Random-header": {"random"}, }, } @@ -238,9 +238,9 @@ func TestCustomNameForwardHeaders(t *testing.T) { params := &common.GraphQLParams{ Query: query, Headers: map[string][]string{ - "App": []string{"app-token"}, - "X-User-Id": []string{"123"}, - "Random-header": []string{"random"}, + "App": {"app-token"}, + "X-User-Id": {"123"}, + "Random-header": {"random"}, }, } diff --git a/graphql/resolve/mutation_test.go b/graphql/resolve/mutation_test.go index be5a32821bf..1516f1963b4 100644 --- a/graphql/resolve/mutation_test.go +++ b/graphql/resolve/mutation_test.go @@ -345,8 +345,8 @@ func TestMutationQueryRewriting(t *testing.T) { } allowedTestTypes := map[string][]string{ - "UPDATE_MUTATION": []string{"Update Post "}, - "ADD_UPDATE_MUTATION": []string{"Add Post ", "Update Post "}, + "UPDATE_MUTATION": {"Update Post "}, + "ADD_UPDATE_MUTATION": {"Add Post ", "Update Post "}, } b, err := ioutil.ReadFile("mutation_query_test.yaml") @@ -421,9 +421,9 @@ func TestCustomHTTPMutation(t *testing.T) { Query: tcase.GQLQuery, Variables: vars, Header: map[string][]string{ - "bogus": []string{"header"}, - "X-App-Token": []string{"val"}, - "Auth0-Token": []string{"tok"}, + "bogus": {"header"}, + "X-App-Token": {"val"}, + "Auth0-Token": {"tok"}, }, }) require.NoError(t, err) diff --git a/graphql/resolve/query_test.go b/graphql/resolve/query_test.go index 7b723373c68..e41a39394a1 100644 --- a/graphql/resolve/query_test.go +++ b/graphql/resolve/query_test.go @@ -151,9 +151,9 @@ func TestCustomHTTPQuery(t *testing.T) { Query: tcase.GQLQuery, Variables: vars, Header: map[string][]string{ - "bogus": []string{"header"}, - "X-App-Token": []string{"val"}, - "Auth0-Token": []string{"tok"}, + "bogus": {"header"}, + "X-App-Token": {"val"}, + "Auth0-Token": {"tok"}, }, }) require.NoError(t, err) diff --git a/graphql/resolve/resolver_test.go b/graphql/resolve/resolver_test.go index b2713b02afc..d1620b3bea7 100644 --- a/graphql/resolve/resolver_test.go +++ b/graphql/resolve/resolver_test.go @@ -35,7 +35,7 @@ func TestErrorOnIncorrectValueType(t *testing.T) { Expected: `{ "getAuthor": { "dob": null }}`, Errors: x.GqlErrorList{{ Message: schema.ErrExpectedScalar, - Locations: []x.Location{x.Location{Line: 1, Column: 32}}, + Locations: []x.Location{{Line: 1, Column: 32}}, Path: []interface{}{"getAuthor", "dob"}, }}}, @@ -45,7 +45,7 @@ func TestErrorOnIncorrectValueType(t *testing.T) { Expected: `{ "getAuthor": { "dob": null }}`, Errors: x.GqlErrorList{{ Message: schema.ErrExpectedScalar, - Locations: []x.Location{x.Location{Line: 1, Column: 32}}, + Locations: []x.Location{{Line: 1, Column: 32}}, Path: []interface{}{"getAuthor", "dob"}, }}}, @@ -55,7 +55,7 @@ func TestErrorOnIncorrectValueType(t *testing.T) { Expected: `{ "getAuthor": { "country": null }}`, Errors: x.GqlErrorList{{ Message: "Error coercing value 'Rwanda' for field 'country' to type Country.", - Locations: []x.Location{x.Location{Line: 1, Column: 32}}, + Locations: []x.Location{{Line: 1, Column: 32}}, Path: []interface{}{"getAuthor", "country"}, }}}, {Name: "return error when array is returned instead of object value", @@ -64,7 +64,7 @@ func TestErrorOnIncorrectValueType(t *testing.T) { Expected: `{ "getAuthor": { "country": null }}`, Errors: x.GqlErrorList{{ Message: schema.ErrExpectedSingleItem, - Locations: []x.Location{x.Location{Line: 1, Column: 32}}, + Locations: []x.Location{{Line: 1, Column: 32}}, Path: []interface{}{"getAuthor", "country"}, }}}, @@ -74,7 +74,7 @@ func TestErrorOnIncorrectValueType(t *testing.T) { Expected: `{ "getAuthor": null}`, Errors: x.GqlErrorList{{ Message: schema.ErrExpectedList, - Locations: []x.Location{x.Location{Line: 1, Column: 32}}, + Locations: []x.Location{{Line: 1, Column: 32}}, Path: []interface{}{"getAuthor"}, }}}, {Name: "return error when object is returned instead of array value", @@ -83,7 +83,7 @@ func TestErrorOnIncorrectValueType(t *testing.T) { Expected: `{ "getAuthor": null}`, Errors: x.GqlErrorList{{ Message: schema.ErrExpectedList, - Locations: []x.Location{x.Location{Line: 1, Column: 32}}, + Locations: []x.Location{{Line: 1, Column: 32}}, Path: []interface{}{"getAuthor"}, }}}, } @@ -123,7 +123,7 @@ func TestValueCoercion(t *testing.T) { Response: `{ "getPost": { "postType": [2] }}`, Errors: x.GqlErrorList{{ Message: "Error coercing value '2' for field 'postType' to type PostType.", - Locations: []x.Location{x.Location{Line: 1, Column: 34}}, + Locations: []x.Location{{Line: 1, Column: 34}}, Path: []interface{}{"getPost", "postType", 0}, }}, Expected: `{ "getPost": { "postType": [null] }}`}, @@ -132,7 +132,7 @@ func TestValueCoercion(t *testing.T) { Response: `{ "getPost": { "postType": [2.134] }}`, Errors: x.GqlErrorList{{ Message: "Error coercing value '2.134' for field 'postType' to type PostType.", - Locations: []x.Location{x.Location{Line: 1, Column: 34}}, + Locations: []x.Location{{Line: 1, Column: 34}}, Path: []interface{}{"getPost", "postType", 0}, }}, Expected: `{ "getPost": { "postType": [null] }}`}, @@ -141,7 +141,7 @@ func TestValueCoercion(t *testing.T) { Response: `{ "getPost": { "postType": [false] }}`, Errors: x.GqlErrorList{{ Message: "Error coercing value 'false' for field 'postType' to type PostType.", - Locations: []x.Location{x.Location{Line: 1, Column: 34}}, + Locations: []x.Location{{Line: 1, Column: 34}}, Path: []interface{}{"getPost", "postType", 0}, }}, Expected: `{ "getPost": { "postType": [null] }}`}, @@ -150,7 +150,7 @@ func TestValueCoercion(t *testing.T) { Response: `{ "getPost": { "postType": ["Random"] }}`, Errors: x.GqlErrorList{{ Message: "Error coercing value 'Random' for field 'postType' to type PostType.", - Locations: []x.Location{x.Location{Line: 1, Column: 34}}, + Locations: []x.Location{{Line: 1, Column: 34}}, Path: []interface{}{"getPost", "postType", 0}, }}, Expected: `{ "getPost": { "postType": [null] }}`}, @@ -213,7 +213,7 @@ func TestValueCoercion(t *testing.T) { Errors: x.GqlErrorList{{ Message: "Error coercing value '2147483648' for field 'numLikes' to type" + " Int.", - Locations: []x.Location{x.Location{Line: 1, Column: 34}}, + Locations: []x.Location{{Line: 1, Column: 34}}, Path: []interface{}{"getPost", "numLikes"}, }}, Expected: `{"getPost": {"numLikes": null}}`, @@ -224,7 +224,7 @@ func TestValueCoercion(t *testing.T) { Response: `{ "getPost": { "numLikes": 123.23 }}`, Errors: x.GqlErrorList{{ Message: "Error coercing value '123.23' for field 'numLikes' to type Int.", - Locations: []x.Location{x.Location{Line: 1, Column: 34}}, + Locations: []x.Location{{Line: 1, Column: 34}}, Path: []interface{}{"getPost", "numLikes"}, }}, Expected: `{"getPost": {"numLikes": null}}`, @@ -235,7 +235,7 @@ func TestValueCoercion(t *testing.T) { Response: `{ "getPost": { "numLikes": "123.23" }}`, Errors: x.GqlErrorList{{ Message: "Error coercing value '123.23' for field 'numLikes' to type Int.", - Locations: []x.Location{x.Location{Line: 1, Column: 34}}, + Locations: []x.Location{{Line: 1, Column: 34}}, Path: []interface{}{"getPost", "numLikes"}, }}, Expected: `{"getPost": {"numLikes": null}}`, @@ -265,7 +265,7 @@ func TestValueCoercion(t *testing.T) { Response: `{ "getAuthor": { "dob": "23.123" }}`, Errors: x.GqlErrorList{{ Message: "Error coercing value '23.123' for field 'dob' to type DateTime.", - Locations: []x.Location{x.Location{Line: 1, Column: 32}}, + Locations: []x.Location{{Line: 1, Column: 32}}, Path: []interface{}{"getAuthor", "dob"}, }}, Expected: `{ "getAuthor": { "dob": null }}`}, @@ -274,7 +274,7 @@ func TestValueCoercion(t *testing.T) { Response: `{ "getAuthor": { "dob": true }}`, Errors: x.GqlErrorList{{ Message: "Error coercing value 'true' for field 'dob' to type DateTime.", - Locations: []x.Location{x.Location{Line: 1, Column: 32}}, + Locations: []x.Location{{Line: 1, Column: 32}}, Path: []interface{}{"getAuthor", "dob"}, }}, Expected: `{ "getAuthor": { "dob": null }}`}, @@ -283,7 +283,7 @@ func TestValueCoercion(t *testing.T) { Response: `{ "getAuthor": { "dob": "123" }}`, Errors: x.GqlErrorList{{ Message: "Error coercing value '123' for field 'dob' to type DateTime.", - Locations: []x.Location{x.Location{Line: 1, Column: 32}}, + Locations: []x.Location{{Line: 1, Column: 32}}, Path: []interface{}{"getAuthor", "dob"}, }}, Expected: `{ "getAuthor": { "dob": null}}`}, diff --git a/query/fastjson_test.go b/query/fastjson_test.go index f0a64258b9f..454c14b861c 100644 --- a/query/fastjson_test.go +++ b/query/fastjson_test.go @@ -17,15 +17,15 @@ func subgraphWithSingleResultAndSingleValue(val *pb.TaskValue) *SubGraph { Params: params{Alias: "query"}, SrcUIDs: &pb.List{Uids: []uint64{1}}, DestUIDs: &pb.List{Uids: []uint64{1}}, - uidMatrix: []*pb.List{&pb.List{Uids: []uint64{1}}}, + uidMatrix: []*pb.List{{Uids: []uint64{1}}}, Children: []*SubGraph{ - &SubGraph{ + { Attr: "val", SrcUIDs: &pb.List{Uids: []uint64{1}}, - uidMatrix: []*pb.List{&pb.List{}}, + uidMatrix: []*pb.List{{}}, valueMatrix: []*pb.ValueList{ // UID 1 - &pb.ValueList{ + { Values: []*pb.TaskValue{val}, }, }, diff --git a/query/outputnode_test.go b/query/outputnode_test.go index 12850ba4c25..7eeca25f6d5 100644 --- a/query/outputnode_test.go +++ b/query/outputnode_test.go @@ -100,9 +100,9 @@ func TestNormalizeJSONLimit(t *testing.T) { func BenchmarkJsonMarshal(b *testing.B) { inputStrings := [][]string{ - []string{"largestring", strings.Repeat("a", 1024)}, - []string{"smallstring", "abcdef"}, - []string{"specialchars", "<><>^)(*&(%*&%&^$*&%)(*&)^)"}, + {"largestring", strings.Repeat("a", 1024)}, + {"smallstring", "abcdef"}, + {"specialchars", "<><>^)(*&(%*&%&^$*&%)(*&)^)"}, } var result []byte diff --git a/query/query1_test.go b/query/query1_test.go index d4c8b5f9741..772cf90efc7 100644 --- a/query/query1_test.go +++ b/query/query1_test.go @@ -355,7 +355,7 @@ func TestGraphQLVarsInUpsert(t *testing.T) { }`, Vars: map[string]string{"$a": "2"}, Mutations: []*api.Mutation{ - &api.Mutation{ + { SetNquads: []byte(`_:user "value" .`), Cond: `@if(eq(len(v), 0))`, }, diff --git a/systest/audit/audit_test.go b/systest/audit/audit_test.go index 6390848c8de..68a63c35ba8 100644 --- a/systest/audit/audit_test.go +++ b/systest/audit/audit_test.go @@ -35,11 +35,11 @@ func TestZeroAudit(t *testing.T) { nId := state.Zeros["1"].Id defer os.RemoveAll(fmt.Sprintf("audit_dir/za/zero_audit_0_%s.log", nId)) zeroCmd := map[string][]string{ - "/removeNode": []string{`--location`, "--request", "GET", + "/removeNode": {`--location`, "--request", "GET", fmt.Sprintf("%s/removeNode?id=3&group=1", testutil.SockAddrZeroHttp)}, - "/assign": []string{"--location", "--request", "GET", + "/assign": {"--location", "--request", "GET", fmt.Sprintf("%s/assign?what=uids&num=100", testutil.SockAddrZeroHttp)}, - "/moveTablet": []string{"--location", "--request", "GET", + "/moveTablet": {"--location", "--request", "GET", fmt.Sprintf("%s/moveTablet?tablet=name&group=2", testutil.SockAddrZeroHttp)}} msgs := make([]string, 0) @@ -66,22 +66,22 @@ func TestAlphaAudit(t *testing.T) { } defer os.Remove(fmt.Sprintf("audit_dir/aa/alpha_audit_1_%s.log", nId)) testCommand := map[string][]string{ - "/admin": []string{"--location", "--request", "POST", + "/admin": {"--location", "--request", "POST", fmt.Sprintf("%s/admin", testutil.SockAddrHttp), "--header", "Content-Type: application/json", "--data-raw", `'{"query":"mutation {\n backup( input: {destination: \"/Users/sankalanparajuli/work/backup\"}) {\n response {\n message\n code\n }\n }\n}\n","variables":{}}'`}, - "/graphql": []string{"--location", "--request", "POST", fmt.Sprintf("%s/graphql", testutil.SockAddrHttp), + "/graphql": {"--location", "--request", "POST", fmt.Sprintf("%s/graphql", testutil.SockAddrHttp), "--header", "Content-Type: application/json", "--data-raw", `'{"query":"query {\n __schema {\n __typename\n }\n}","variables":{}}'`}, - "/alter": []string{"-X", "POST", fmt.Sprintf("%s/alter", testutil.SockAddrHttp), "-d", + "/alter": {"-X", "POST", fmt.Sprintf("%s/alter", testutil.SockAddrHttp), "-d", `name: string @index(term) . type Person { name }`}, - "/query": []string{"-H", "'Content-Type: application/dql'", "-X", "POST", fmt.Sprintf("%s/query", testutil.SockAddrHttp), + "/query": {"-H", "'Content-Type: application/dql'", "-X", "POST", fmt.Sprintf("%s/query", testutil.SockAddrHttp), "-d", `$' { balances(func: anyofterms(name, "Alice Bob")) { @@ -90,7 +90,7 @@ input: {destination: \"/Users/sankalanparajuli/work/backup\"}) {\n response { balance } }'`}, - "/mutate": []string{"-H", "'Content-Type: application/rdf'", "-X", + "/mutate": {"-H", "'Content-Type: application/rdf'", "-X", "POST", fmt.Sprintf("%s/mutate?startTs=4", testutil.SockAddrHttp), "-d", `$' { set { diff --git a/worker/backup_manifest.go b/worker/backup_manifest.go index e098e1bae46..4c79f844f73 100644 --- a/worker/backup_manifest.go +++ b/worker/backup_manifest.go @@ -99,7 +99,7 @@ func getFilteredManifests(h UriHandler, manifests []*Manifest, var validManifests []*Manifest for _, m := range manifests { missingFiles := false - for g, _ := range m.Groups { + for g := range m.Groups { path := filepath.Join(m.Path, backupName(m.ValidReadTs(), g)) if !h.FileExists(path) { missingFiles = true