diff --git a/expression/expressions/helper_test.go b/expression/expressions/helper_test.go index a9320da1f159b..ea94b75c41b00 100644 --- a/expression/expressions/helper_test.go +++ b/expression/expressions/helper_test.go @@ -36,7 +36,7 @@ func (s *testHelperSuite) TestContainAggFunc(c *C) { {&FunctionCast{Expr: v}, false}, {&FunctionConvert{Expr: v}, false}, {&FunctionSubstring{StrExpr: v, Pos: v, Len: v}, false}, - {&FunctionCase{Value: v, WhenClauses: []*WhenClause{&WhenClause{Expr: v, Result: v}}, ElseClause: v}, false}, + {&FunctionCase{Value: v, WhenClauses: []*WhenClause{{Expr: v, Result: v}}, ElseClause: v}, false}, {&WhenClause{Expr: v, Result: v}, false}, {&IsTruth{Expr: v}, false}, {&Between{Expr: v, Left: v, Right: v}, false}, @@ -67,7 +67,7 @@ func (s *testHelperSuite) TestMentionedColumns(c *C) { {&FunctionCast{Expr: v}, 0}, {&FunctionConvert{Expr: v}, 0}, {&FunctionSubstring{StrExpr: v, Pos: v, Len: v}, 0}, - {&FunctionCase{Value: v, WhenClauses: []*WhenClause{&WhenClause{Expr: v, Result: v}}, ElseClause: v}, 0}, + {&FunctionCase{Value: v, WhenClauses: []*WhenClause{{Expr: v, Result: v}}, ElseClause: v}, 0}, {&WhenClause{Expr: v, Result: v}, 0}, {&IsTruth{Expr: v}, 0}, {&Between{Expr: v, Left: v, Right: v}, 0}, diff --git a/infoschema/infoschema_test.go b/infoschema/infoschema_test.go index c57475cc10c42..0044755ad6ad8 100644 --- a/infoschema/infoschema_test.go +++ b/infoschema/infoschema_test.go @@ -62,7 +62,7 @@ func (*testSuite) TestT(c *C) { Name: idxName, Table: tbName, Columns: []*model.IndexColumn{ - &model.IndexColumn{ + { Name: colName, Offset: 0, Length: 10, diff --git a/parser/coldef/col_def.go b/parser/coldef/col_def.go index 8d60f8bfe8018..aa87c2cd3708f 100644 --- a/parser/coldef/col_def.go +++ b/parser/coldef/col_def.go @@ -189,7 +189,7 @@ func ColumnDefToCol(offset int, colDef *ColumnDef) (*column.Col, []*TableConstra hasDefaultValue := false if colDef.Constraints != nil { keys := []*IndexColName{ - &IndexColName{ + { colDef.Name, colDef.Tp.Flen, }, diff --git a/plan/plans/distinct_test.go b/plan/plans/distinct_test.go index 4c49e5d9dfabc..567af7ac46276 100644 --- a/plan/plans/distinct_test.go +++ b/plan/plans/distinct_test.go @@ -40,11 +40,11 @@ type testTablePlan struct { } var distinctTestData = []*testRowData{ - &testRowData{1, []interface{}{10, "hello"}}, - &testRowData{2, []interface{}{10, "hello"}}, - &testRowData{3, []interface{}{10, "hello"}}, - &testRowData{4, []interface{}{40, "hello"}}, - &testRowData{6, []interface{}{60, "hello"}}, + {1, []interface{}{10, "hello"}}, + {2, []interface{}{10, "hello"}}, + {3, []interface{}{10, "hello"}}, + {4, []interface{}{40, "hello"}}, + {6, []interface{}{60, "hello"}}, } func (p *testTablePlan) Do(ctx context.Context, f plan.RowIterFunc) error { @@ -94,9 +94,9 @@ func (t *testDistinctSuit) TestDistinct(c *C) { c.Assert(err, IsNil) expected := map[int][]interface{}{ - 10: []interface{}{10, "hello"}, - 40: []interface{}{40, "hello"}, - 60: []interface{}{60, "hello"}, + 10: {10, "hello"}, + 40: {40, "hello"}, + 60: {60, "hello"}, } c.Assert(reflect.DeepEqual(r, expected), Equals, true) diff --git a/plan/plans/explain.go b/plan/plans/explain.go index c9c288b7bb63e..4221c7f057821 100644 --- a/plan/plans/explain.go +++ b/plan/plans/explain.go @@ -57,7 +57,7 @@ func (r *ExplainDefaultPlan) Explain(w format.Formatter) { // GetFields implements the plan.Plan GetFields interface. func (r *ExplainDefaultPlan) GetFields() []*field.ResultField { - return []*field.ResultField{&field.ResultField{Name: ""}} + return []*field.ResultField{{Name: ""}} } // Filter implements the plan.Plan Filter interface. diff --git a/plan/plans/fields_test.go b/plan/plans/fields_test.go index 5c8977b1c2d4b..391d2250c1b72 100644 --- a/plan/plans/fields_test.go +++ b/plan/plans/fields_test.go @@ -25,12 +25,12 @@ type testFieldsSuit struct{} var _ = Suite(&testFieldsSuit{}) var selectFieldsTestData = []*testRowData{ - &testRowData{1, []interface{}{10, "hello"}}, - &testRowData{2, []interface{}{20, "hello"}}, - &testRowData{3, []interface{}{30, "hello"}}, - &testRowData{4, []interface{}{40, "hello"}}, - &testRowData{5, []interface{}{50, "hello"}}, - &testRowData{6, []interface{}{60, "hello"}}, + {1, []interface{}{10, "hello"}}, + {2, []interface{}{20, "hello"}}, + {3, []interface{}{30, "hello"}}, + {4, []interface{}{40, "hello"}}, + {5, []interface{}{50, "hello"}}, + {6, []interface{}{60, "hello"}}, } func (s *testFieldsSuit) TestDefaultFieldsPlan(c *C) { @@ -38,7 +38,7 @@ func (s *testFieldsSuit) TestDefaultFieldsPlan(c *C) { sl1 := &SelectList{ Fields: []*field.Field{ - &field.Field{ + { Expr: &expressions.Ident{ CIStr: model.NewCIStr("name"), }, @@ -60,12 +60,12 @@ func (s *testFieldsSuit) TestDefaultFieldsPlan(c *C) { // test multiple fields sl2 := &SelectList{ Fields: []*field.Field{ - &field.Field{ + { Expr: &expressions.Ident{ CIStr: model.NewCIStr("name"), }, }, - &field.Field{ + { Expr: &expressions.Ident{ CIStr: model.NewCIStr("id"), }, @@ -88,7 +88,7 @@ func (s *testFieldsSuit) TestDefaultFieldsPlan(c *C) { // test field doesn't exists sl3 := &SelectList{ Fields: []*field.Field{ - &field.Field{ + { Expr: &expressions.Ident{ CIStr: model.NewCIStr("nosuchfield"), }, @@ -108,7 +108,7 @@ func (s *testFieldsSuit) TestDefaultFieldsPlan(c *C) { func (s *testFieldsSuit) TestSelectExprPlan(c *C) { pln := &SelectEmptyFieldListPlan{ Fields: []*field.Field{ - &field.Field{ + { Expr: &expressions.Value{ Val: "data", }, diff --git a/plan/plans/final_test.go b/plan/plans/final_test.go index fc10a966ebdb0..db99dcbf8a7dd 100644 --- a/plan/plans/final_test.go +++ b/plan/plans/final_test.go @@ -27,11 +27,11 @@ type testFinalPlan struct{} var _ = Suite(&testFinalPlan{}) var finalTestData = []*testRowData{ - &testRowData{1, []interface{}{10, "hello", true}}, - &testRowData{2, []interface{}{10, "hello", true}}, - &testRowData{3, []interface{}{10, "hello", true}}, - &testRowData{4, []interface{}{40, "hello", true}}, - &testRowData{6, []interface{}{60, "hello", false}}, + {1, []interface{}{10, "hello", true}}, + {2, []interface{}{10, "hello", true}}, + {3, []interface{}{10, "hello", true}}, + {4, []interface{}{40, "hello", true}}, + {6, []interface{}{60, "hello", false}}, } func (t *testFinalPlan) TestFinalPlan(c *C) { diff --git a/plan/plans/from_test.go b/plan/plans/from_test.go index 06f955308c0b8..e816c871c3ec7 100644 --- a/plan/plans/from_test.go +++ b/plan/plans/from_test.go @@ -78,7 +78,7 @@ func (p *testFromSuit) SetUpSuite(c *C) { p.vars = map[string]interface{}{} p.txn, _ = store.Begin() p.cols = []*column.Col{ - &column.Col{ + { ColumnInfo: model.ColumnInfo{ ID: 0, Name: model.NewCIStr("id"), @@ -87,7 +87,7 @@ func (p *testFromSuit) SetUpSuite(c *C) { FieldType: *types.NewFieldType(mysql.TypeLonglong), }, }, - &column.Col{ + { ColumnInfo: model.ColumnInfo{ ID: 1, Name: model.NewCIStr("name"), @@ -158,7 +158,7 @@ func (p *testFromSuit) TestTableDefaultPlan(c *C) { Name: model.NewCIStr("id"), Table: model.NewCIStr("t"), Columns: []*model.IndexColumn{ - &model.IndexColumn{ + { Name: model.NewCIStr("id"), Offset: 0, Length: 0, diff --git a/plan/plans/groupby_test.go b/plan/plans/groupby_test.go index c48945e3c7ae4..c65d931cd4e8b 100644 --- a/plan/plans/groupby_test.go +++ b/plan/plans/groupby_test.go @@ -26,11 +26,11 @@ type testGroupBySuite struct{} var _ = Suite(&testGroupBySuite{}) var groupByTestData = []*testRowData{ - &testRowData{1, []interface{}{10, "10"}}, - &testRowData{2, []interface{}{10, "20"}}, - &testRowData{3, []interface{}{10, "30"}}, - &testRowData{4, []interface{}{40, "40"}}, - &testRowData{6, []interface{}{60, "60"}}, + {1, []interface{}{10, "10"}}, + {2, []interface{}{10, "20"}}, + {3, []interface{}{10, "30"}}, + {4, []interface{}{40, "40"}}, + {6, []interface{}{60, "60"}}, } func (t *testGroupBySuite) TestGroupBy(c *C) { @@ -38,17 +38,17 @@ func (t *testGroupBySuite) TestGroupBy(c *C) { // test multiple fields sl := &SelectList{ Fields: []*field.Field{ - &field.Field{ + { Expr: &expressions.Ident{ CIStr: model.NewCIStr("id"), }, }, - &field.Field{ + { Expr: &expressions.Ident{ CIStr: model.NewCIStr("name"), }, }, - &field.Field{ + { Expr: &expressions.Call{ F: "sum", Args: []expression.Expression{ @@ -59,7 +59,7 @@ func (t *testGroupBySuite) TestGroupBy(c *C) { }, }, }, - AggFields: map[int]struct{}{2: struct{}{}}, + AggFields: map[int]struct{}{2: {}}, } groupbyPlan := &GroupByDefaultPlan{ diff --git a/plan/plans/having_test.go b/plan/plans/having_test.go index 042d71a937c9c..476266fd77a2e 100644 --- a/plan/plans/having_test.go +++ b/plan/plans/having_test.go @@ -25,11 +25,11 @@ type testHavingPlan struct{} var _ = Suite(&testHavingPlan{}) var havingTestData = []*testRowData{ - &testRowData{1, []interface{}{10, "10"}}, - &testRowData{2, []interface{}{10, "20"}}, - &testRowData{3, []interface{}{10, "30"}}, - &testRowData{4, []interface{}{40, "40"}}, - &testRowData{6, []interface{}{60, "60"}}, + {1, []interface{}{10, "10"}}, + {2, []interface{}{10, "20"}}, + {3, []interface{}{10, "30"}}, + {4, []interface{}{40, "40"}}, + {6, []interface{}{60, "60"}}, } func (t *testHavingPlan) TestHaving(c *C) { diff --git a/plan/plans/index_test.go b/plan/plans/index_test.go index 28fb4ed3598af..46ee2179c1693 100644 --- a/plan/plans/index_test.go +++ b/plan/plans/index_test.go @@ -67,7 +67,7 @@ func (p *testIndexSuit) SetUpSuite(c *C) { p.vars = map[string]interface{}{} p.txn, _ = p.store.Begin() p.cols = []*column.Col{ - &column.Col{ + { ColumnInfo: model.ColumnInfo{ ID: 0, Name: model.NewCIStr("id"), @@ -76,7 +76,7 @@ func (p *testIndexSuit) SetUpSuite(c *C) { FieldType: *types.NewFieldType(mysql.TypeLonglong), }, }, - &column.Col{ + { ColumnInfo: model.ColumnInfo{ ID: 1, Name: model.NewCIStr("name"), @@ -93,7 +93,7 @@ func (p *testIndexSuit) SetUpSuite(c *C) { Name: model.NewCIStr("id"), Table: model.NewCIStr("t2"), Columns: []*model.IndexColumn{ - &model.IndexColumn{ + { Name: model.NewCIStr("id"), Offset: 0, Length: 0, diff --git a/plan/plans/join_test.go b/plan/plans/join_test.go index a9ef4c3d64fa0..ed7db68750064 100644 --- a/plan/plans/join_test.go +++ b/plan/plans/join_test.go @@ -32,7 +32,7 @@ var _ = Suite(&testJoinSuit{}) func (s *testJoinSuit) TestJoin(c *C) { s.cols = []*column.Col{ - &column.Col{ + { ColumnInfo: model.ColumnInfo{ ID: 0, Name: model.NewCIStr("id"), @@ -41,7 +41,7 @@ func (s *testJoinSuit) TestJoin(c *C) { FieldType: *types.NewFieldType(mysql.TypeLonglong), }, }, - &column.Col{ + { ColumnInfo: model.ColumnInfo{ ID: 1, Name: model.NewCIStr("name"), @@ -53,19 +53,19 @@ func (s *testJoinSuit) TestJoin(c *C) { } var testData1 = []*testRowData{ - &testRowData{1, []interface{}{10, "10"}}, - &testRowData{2, []interface{}{10, "20"}}, - &testRowData{3, []interface{}{10, "30"}}, - &testRowData{4, []interface{}{40, "40"}}, - &testRowData{6, []interface{}{60, "60"}}, + {1, []interface{}{10, "10"}}, + {2, []interface{}{10, "20"}}, + {3, []interface{}{10, "30"}}, + {4, []interface{}{40, "40"}}, + {6, []interface{}{60, "60"}}, } var testData2 = []*testRowData{ - &testRowData{1, []interface{}{10, "10"}}, - &testRowData{2, []interface{}{10, "20"}}, - &testRowData{3, []interface{}{10, "30"}}, - &testRowData{4, []interface{}{40, "40"}}, - &testRowData{6, []interface{}{60, "60"}}, + {1, []interface{}{10, "10"}}, + {2, []interface{}{10, "20"}}, + {3, []interface{}{10, "30"}}, + {4, []interface{}{40, "40"}}, + {6, []interface{}{60, "60"}}, } tblPlan1 := &testTablePlan{testData1, []string{"id", "name"}} diff --git a/plan/plans/limit_test.go b/plan/plans/limit_test.go index d647d10693637..6a25a1f8c681e 100644 --- a/plan/plans/limit_test.go +++ b/plan/plans/limit_test.go @@ -66,11 +66,11 @@ type testLimitSuit struct { var _ = Suite(&testLimitSuit{ data: []*testRowData{ - &testRowData{1, []interface{}{10, "10"}}, - &testRowData{2, []interface{}{10, "20"}}, - &testRowData{3, []interface{}{10, "30"}}, - &testRowData{4, []interface{}{40, "40"}}, - &testRowData{6, []interface{}{60, "60"}}, + {1, []interface{}{10, "10"}}, + {2, []interface{}{10, "20"}}, + {3, []interface{}{10, "30"}}, + {4, []interface{}{40, "40"}}, + {6, []interface{}{60, "60"}}, }, }) diff --git a/plan/plans/orderby_test.go b/plan/plans/orderby_test.go index ae231ee8b7470..9dca998806df5 100644 --- a/plan/plans/orderby_test.go +++ b/plan/plans/orderby_test.go @@ -27,11 +27,11 @@ type testOrderBySuit struct { var _ = Suite(&testOrderBySuit{ []*testRowData{ - &testRowData{1, []interface{}{10, "10"}}, - &testRowData{2, []interface{}{10, "20"}}, - &testRowData{3, []interface{}{10, "30"}}, - &testRowData{4, []interface{}{40, "40"}}, - &testRowData{6, []interface{}{60, "60"}}, + {1, []interface{}{10, "10"}}, + {2, []interface{}{10, "20"}}, + {3, []interface{}{10, "30"}}, + {4, []interface{}{40, "40"}}, + {6, []interface{}{60, "60"}}, }, }) diff --git a/plan/plans/plans.go b/plan/plans/plans.go index 0a4764aec526e..1f658980c8219 100644 --- a/plan/plans/plans.go +++ b/plan/plans/plans.go @@ -108,7 +108,7 @@ func (r *selectIndexDefaultPlan) Do(ctx context.Context, f plan.RowIterFunc) (er // GetFields implements plan.Plan GetFields interface. func (r *selectIndexDefaultPlan) GetFields() []*field.ResultField { - return []*field.ResultField{&field.ResultField{Name: r.nm}} + return []*field.ResultField{{Name: r.nm}} } // NullPlan is empty plan, if we can affirm that the resultset is empty, we diff --git a/plan/plans/union_test.go b/plan/plans/union_test.go index da6799f8920a8..a43c22c54a230 100644 --- a/plan/plans/union_test.go +++ b/plan/plans/union_test.go @@ -30,18 +30,18 @@ type testUnionSuit struct { var _ = Suite(&testUnionSuit{ data: []*testRowData{ - &testRowData{1, []interface{}{10, "10"}}, - &testRowData{2, []interface{}{10, "20"}}, - &testRowData{3, []interface{}{10, "30"}}, - &testRowData{4, []interface{}{40, "40"}}, - &testRowData{6, []interface{}{60, "60"}}, + {1, []interface{}{10, "10"}}, + {2, []interface{}{10, "20"}}, + {3, []interface{}{10, "30"}}, + {4, []interface{}{40, "40"}}, + {6, []interface{}{60, "60"}}, }, data2: []*testRowData{ - &testRowData{1, []interface{}{10, "10"}}, - &testRowData{2, []interface{}{10, "20"}}, - &testRowData{3, []interface{}{10, "30"}}, - &testRowData{4, []interface{}{40, "40"}}, - &testRowData{6, []interface{}{70, "60"}}, + {1, []interface{}{10, "10"}}, + {2, []interface{}{10, "20"}}, + {3, []interface{}{10, "30"}}, + {4, []interface{}{40, "40"}}, + {6, []interface{}{70, "60"}}, }, }) @@ -49,7 +49,7 @@ func (t *testUnionSuit) TestUnion(c *C) { tblPlan := &testTablePlan{t.data, []string{"id", "name"}} tblPlan2 := &testTablePlan{t.data2, []string{"id", "name"}} cols := []*column.Col{ - &column.Col{ + { ColumnInfo: model.ColumnInfo{ ID: 0, Name: model.NewCIStr("id"), @@ -58,7 +58,7 @@ func (t *testUnionSuit) TestUnion(c *C) { FieldType: *types.NewFieldType(mysql.TypeLonglong), }, }, - &column.Col{ + { ColumnInfo: model.ColumnInfo{ ID: 1, Name: model.NewCIStr("name"), diff --git a/plan/plans/where_test.go b/plan/plans/where_test.go index f6fe0add49d64..918c15fbe6080 100644 --- a/plan/plans/where_test.go +++ b/plan/plans/where_test.go @@ -26,11 +26,11 @@ type testWhereSuit struct { var _ = Suite(&testWhereSuit{ data: []*testRowData{ - &testRowData{1, []interface{}{10, "10"}}, - &testRowData{2, []interface{}{10, "20"}}, - &testRowData{3, []interface{}{10, "30"}}, - &testRowData{4, []interface{}{40, "40"}}, - &testRowData{6, []interface{}{60, "60"}}, + {1, []interface{}{10, "10"}}, + {2, []interface{}{10, "20"}}, + {3, []interface{}{10, "30"}}, + {4, []interface{}{40, "40"}}, + {6, []interface{}{60, "60"}}, }, }) diff --git a/rset/rsets/rsets_test.go b/rset/rsets/rsets_test.go index 1069dfb558b37..c4800bebae793 100644 --- a/rset/rsets/rsets_test.go +++ b/rset/rsets/rsets_test.go @@ -42,11 +42,11 @@ type testTablePlan struct { } var testData = []*testRowData{ - &testRowData{1, []interface{}{10, "hello"}}, - &testRowData{2, []interface{}{10, "hello"}}, - &testRowData{3, []interface{}{10, "hello"}}, - &testRowData{4, []interface{}{40, "hello"}}, - &testRowData{6, []interface{}{60, "hello"}}, + {1, []interface{}{10, "hello"}}, + {2, []interface{}{10, "hello"}}, + {3, []interface{}{10, "hello"}}, + {4, []interface{}{40, "hello"}}, + {6, []interface{}{60, "hello"}}, } func newTestTablePlan(rows []*testRowData, fields []string) *testTablePlan { diff --git a/util/codec/codec_test.go b/util/codec/codec_test.go index df74752a9e008..3b096d9ffd5a8 100644 --- a/util/codec/codec_test.go +++ b/util/codec/codec_test.go @@ -360,10 +360,10 @@ func (s *testCodecSuite) TestFloatCodec(c *C) { func (s *testCodecSuite) TestBytes(c *C) { tblBytes := [][]byte{ - []byte{}, - []byte{0x00, 0x01}, - []byte{0xff, 0xff}, - []byte{0x01, 0x00}, + {}, + {0x00, 0x01}, + {0xff, 0xff}, + {0x01, 0x00}, []byte("abc"), []byte("hello world"), } diff --git a/util/printer/printer_test.go b/util/printer/printer_test.go index 6ca6914b407a1..71ac3482fad8d 100644 --- a/util/printer/printer_test.go +++ b/util/printer/printer_test.go @@ -30,12 +30,12 @@ type testPrinterSuite struct { func (s *testPrinterSuite) TestPrintResult(c *C) { cols := []string{"col1", "col2", "col3"} - datas := [][]string{[]string{"11"}, []string{"21", "22", "23"}} + datas := [][]string{{"11"}, {"21", "22", "23"}} result, ok := GetPrintResult(cols, datas) c.Assert(ok, IsFalse) c.Assert(result, Equals, "") - datas = [][]string{[]string{"11", "12", "13"}, []string{"21", "22", "23"}} + datas = [][]string{{"11", "12", "13"}, {"21", "22", "23"}} expect := ` +------+------+------+ | col1 | col2 | col3 |