Browse Source

chore: gofumpt (#2439)

Kevin Wan 2 years ago
parent
commit
1a6d7b3ef6

+ 1 - 1
core/discov/internal/registry_test.go

@@ -2,7 +2,6 @@ package internal
 
 
 import (
 import (
 	"context"
 	"context"
-	"go.etcd.io/etcd/api/v3/etcdserverpb"
 	"sync"
 	"sync"
 	"testing"
 	"testing"
 
 
@@ -12,6 +11,7 @@ import (
 	"github.com/zeromicro/go-zero/core/lang"
 	"github.com/zeromicro/go-zero/core/lang"
 	"github.com/zeromicro/go-zero/core/logx"
 	"github.com/zeromicro/go-zero/core/logx"
 	"github.com/zeromicro/go-zero/core/stringx"
 	"github.com/zeromicro/go-zero/core/stringx"
+	"go.etcd.io/etcd/api/v3/etcdserverpb"
 	"go.etcd.io/etcd/api/v3/mvccpb"
 	"go.etcd.io/etcd/api/v3/mvccpb"
 	clientv3 "go.etcd.io/etcd/client/v3"
 	clientv3 "go.etcd.io/etcd/client/v3"
 )
 )

+ 1 - 1
core/mapping/yamlunmarshaler.go

@@ -63,7 +63,7 @@ func cleanupMapValue(v interface{}) interface{} {
 	}
 	}
 }
 }
 
 
-func unmarshal(unmarshaler *Unmarshaler, o interface{}, v interface{}) error {
+func unmarshal(unmarshaler *Unmarshaler, o, v interface{}) error {
 	if m, ok := o.(map[string]interface{}); ok {
 	if m, ok := o.(map[string]interface{}); ok {
 		return unmarshaler.Unmarshal(m, v)
 		return unmarshaler.Unmarshal(m, v)
 	}
 	}

+ 1 - 1
core/mr/mapreduce_fuzz_test.go

@@ -19,7 +19,7 @@ func FuzzMapReduce(f *testing.F) {
 	rand.Seed(time.Now().UnixNano())
 	rand.Seed(time.Now().UnixNano())
 
 
 	f.Add(uint(10), uint(runtime.NumCPU()))
 	f.Add(uint(10), uint(runtime.NumCPU()))
-	f.Fuzz(func(t *testing.T, num uint, workers uint) {
+	f.Fuzz(func(t *testing.T, num, workers uint) {
 		n := int64(num)%5000 + 5000
 		n := int64(num)%5000 + 5000
 		genPanic := rand.Intn(100) == 0
 		genPanic := rand.Intn(100) == 0
 		mapperPanic := rand.Intn(100) == 0
 		mapperPanic := rand.Intn(100) == 0

+ 11 - 11
core/stores/mon/collection.go

@@ -83,12 +83,12 @@ type (
 		// FindOneAndReplace returns at most one document that matches the filter. If the filter
 		// FindOneAndReplace returns at most one document that matches the filter. If the filter
 		// matches multiple documents, FindOneAndReplace returns the first document in the
 		// matches multiple documents, FindOneAndReplace returns the first document in the
 		// collection that matches the filter.
 		// collection that matches the filter.
-		FindOneAndReplace(ctx context.Context, filter interface{}, replacement interface{},
+		FindOneAndReplace(ctx context.Context, filter, replacement interface{},
 			opts ...*mopt.FindOneAndReplaceOptions) (*mongo.SingleResult, error)
 			opts ...*mopt.FindOneAndReplaceOptions) (*mongo.SingleResult, error)
 		// FindOneAndUpdate returns at most one document that matches the filter. If the filter
 		// FindOneAndUpdate returns at most one document that matches the filter. If the filter
 		// matches multiple documents, FindOneAndUpdate returns the first document in the
 		// matches multiple documents, FindOneAndUpdate returns the first document in the
 		// collection that matches the filter.
 		// collection that matches the filter.
-		FindOneAndUpdate(ctx context.Context, filter interface{}, update interface{},
+		FindOneAndUpdate(ctx context.Context, filter, update interface{},
 			opts ...*mopt.FindOneAndUpdateOptions) (*mongo.SingleResult, error)
 			opts ...*mopt.FindOneAndUpdateOptions) (*mongo.SingleResult, error)
 		// Indexes returns the index view for this collection.
 		// Indexes returns the index view for this collection.
 		Indexes() mongo.IndexView
 		Indexes() mongo.IndexView
@@ -99,16 +99,16 @@ type (
 		InsertOne(ctx context.Context, document interface{}, opts ...*mopt.InsertOneOptions) (
 		InsertOne(ctx context.Context, document interface{}, opts ...*mopt.InsertOneOptions) (
 			*mongo.InsertOneResult, error)
 			*mongo.InsertOneResult, error)
 		// ReplaceOne replaces at most one document that matches the filter.
 		// ReplaceOne replaces at most one document that matches the filter.
-		ReplaceOne(ctx context.Context, filter interface{}, replacement interface{},
+		ReplaceOne(ctx context.Context, filter, replacement interface{},
 			opts ...*mopt.ReplaceOptions) (*mongo.UpdateResult, error)
 			opts ...*mopt.ReplaceOptions) (*mongo.UpdateResult, error)
 		// UpdateByID updates a single document matching the provided filter.
 		// UpdateByID updates a single document matching the provided filter.
-		UpdateByID(ctx context.Context, id interface{}, update interface{},
+		UpdateByID(ctx context.Context, id, update interface{},
 			opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error)
 			opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error)
 		// UpdateMany updates the provided documents.
 		// UpdateMany updates the provided documents.
-		UpdateMany(ctx context.Context, filter interface{}, update interface{},
+		UpdateMany(ctx context.Context, filter, update interface{},
 			opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error)
 			opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error)
 		// UpdateOne updates a single document matching the provided filter.
 		// UpdateOne updates a single document matching the provided filter.
-		UpdateOne(ctx context.Context, filter interface{}, update interface{},
+		UpdateOne(ctx context.Context, filter, update interface{},
 			opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error)
 			opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error)
 		// Watch returns a change stream cursor used to receive notifications of changes to the collection.
 		// Watch returns a change stream cursor used to receive notifications of changes to the collection.
 		Watch(ctx context.Context, pipeline interface{}, opts ...*mopt.ChangeStreamOptions) (
 		Watch(ctx context.Context, pipeline interface{}, opts ...*mopt.ChangeStreamOptions) (
@@ -359,7 +359,7 @@ func (c *decoratedCollection) FindOneAndReplace(ctx context.Context, filter inte
 	return
 	return
 }
 }
 
 
-func (c *decoratedCollection) FindOneAndUpdate(ctx context.Context, filter interface{}, update interface{},
+func (c *decoratedCollection) FindOneAndUpdate(ctx context.Context, filter, update interface{},
 	opts ...*mopt.FindOneAndUpdateOptions) (res *mongo.SingleResult, err error) {
 	opts ...*mopt.FindOneAndUpdateOptions) (res *mongo.SingleResult, err error) {
 	ctx, span := startSpan(ctx, findOneAndUpdate)
 	ctx, span := startSpan(ctx, findOneAndUpdate)
 	defer func() {
 	defer func() {
@@ -420,7 +420,7 @@ func (c *decoratedCollection) InsertOne(ctx context.Context, document interface{
 	return
 	return
 }
 }
 
 
-func (c *decoratedCollection) ReplaceOne(ctx context.Context, filter interface{}, replacement interface{},
+func (c *decoratedCollection) ReplaceOne(ctx context.Context, filter, replacement interface{},
 	opts ...*mopt.ReplaceOptions) (res *mongo.UpdateResult, err error) {
 	opts ...*mopt.ReplaceOptions) (res *mongo.UpdateResult, err error) {
 	ctx, span := startSpan(ctx, replaceOne)
 	ctx, span := startSpan(ctx, replaceOne)
 	defer func() {
 	defer func() {
@@ -440,7 +440,7 @@ func (c *decoratedCollection) ReplaceOne(ctx context.Context, filter interface{}
 	return
 	return
 }
 }
 
 
-func (c *decoratedCollection) UpdateByID(ctx context.Context, id interface{}, update interface{},
+func (c *decoratedCollection) UpdateByID(ctx context.Context, id, update interface{},
 	opts ...*mopt.UpdateOptions) (res *mongo.UpdateResult, err error) {
 	opts ...*mopt.UpdateOptions) (res *mongo.UpdateResult, err error) {
 	ctx, span := startSpan(ctx, updateByID)
 	ctx, span := startSpan(ctx, updateByID)
 	defer func() {
 	defer func() {
@@ -460,7 +460,7 @@ func (c *decoratedCollection) UpdateByID(ctx context.Context, id interface{}, up
 	return
 	return
 }
 }
 
 
-func (c *decoratedCollection) UpdateMany(ctx context.Context, filter interface{}, update interface{},
+func (c *decoratedCollection) UpdateMany(ctx context.Context, filter, update interface{},
 	opts ...*mopt.UpdateOptions) (res *mongo.UpdateResult, err error) {
 	opts ...*mopt.UpdateOptions) (res *mongo.UpdateResult, err error) {
 	ctx, span := startSpan(ctx, updateMany)
 	ctx, span := startSpan(ctx, updateMany)
 	defer func() {
 	defer func() {
@@ -480,7 +480,7 @@ func (c *decoratedCollection) UpdateMany(ctx context.Context, filter interface{}
 	return
 	return
 }
 }
 
 
-func (c *decoratedCollection) UpdateOne(ctx context.Context, filter interface{}, update interface{},
+func (c *decoratedCollection) UpdateOne(ctx context.Context, filter, update interface{},
 	opts ...*mopt.UpdateOptions) (res *mongo.UpdateResult, err error) {
 	opts ...*mopt.UpdateOptions) (res *mongo.UpdateResult, err error) {
 	ctx, span := startSpan(ctx, updateOne)
 	ctx, span := startSpan(ctx, updateOne)
 	defer func() {
 	defer func() {

+ 4 - 4
core/stores/mon/collection_test.go

@@ -106,14 +106,14 @@ func TestCollection_BulkWrite(t *testing.T) {
 		}
 		}
 		mt.AddMockResponses(mtest.CreateSuccessResponse(bson.D{{Key: "ok", Value: 1}}...))
 		mt.AddMockResponses(mtest.CreateSuccessResponse(bson.D{{Key: "ok", Value: 1}}...))
 		res, err := c.BulkWrite(context.Background(), []mongo.WriteModel{
 		res, err := c.BulkWrite(context.Background(), []mongo.WriteModel{
-			mongo.NewInsertOneModel().SetDocument(bson.D{{Key: "foo", Value: 1}})},
-		)
+			mongo.NewInsertOneModel().SetDocument(bson.D{{Key: "foo", Value: 1}}),
+		})
 		assert.Nil(t, err)
 		assert.Nil(t, err)
 		assert.NotNil(t, res)
 		assert.NotNil(t, res)
 		c.brk = new(dropBreaker)
 		c.brk = new(dropBreaker)
 		_, err = c.BulkWrite(context.Background(), []mongo.WriteModel{
 		_, err = c.BulkWrite(context.Background(), []mongo.WriteModel{
-			mongo.NewInsertOneModel().SetDocument(bson.D{{Key: "foo", Value: 1}})},
-		)
+			mongo.NewInsertOneModel().SetDocument(bson.D{{Key: "foo", Value: 1}}),
+		})
 		assert.Equal(t, errDummy, err)
 		assert.Equal(t, errDummy, err)
 	})
 	})
 }
 }

+ 2 - 2
core/stores/mon/model.go

@@ -159,7 +159,7 @@ func (m *Model) FindOneAndDelete(ctx context.Context, v, filter interface{},
 }
 }
 
 
 // FindOneAndReplace finds a single document and replaces it.
 // FindOneAndReplace finds a single document and replaces it.
-func (m *Model) FindOneAndReplace(ctx context.Context, v, filter interface{}, replacement interface{},
+func (m *Model) FindOneAndReplace(ctx context.Context, v, filter, replacement interface{},
 	opts ...*mopt.FindOneAndReplaceOptions) error {
 	opts ...*mopt.FindOneAndReplaceOptions) error {
 	res, err := m.Collection.FindOneAndReplace(ctx, filter, replacement, opts...)
 	res, err := m.Collection.FindOneAndReplace(ctx, filter, replacement, opts...)
 	if err != nil {
 	if err != nil {
@@ -170,7 +170,7 @@ func (m *Model) FindOneAndReplace(ctx context.Context, v, filter interface{}, re
 }
 }
 
 
 // FindOneAndUpdate finds a single document and updates it.
 // FindOneAndUpdate finds a single document and updates it.
-func (m *Model) FindOneAndUpdate(ctx context.Context, v, filter interface{}, update interface{},
+func (m *Model) FindOneAndUpdate(ctx context.Context, v, filter, update interface{},
 	opts ...*mopt.FindOneAndUpdateOptions) error {
 	opts ...*mopt.FindOneAndUpdateOptions) error {
 	res, err := m.Collection.FindOneAndUpdate(ctx, filter, update, opts...)
 	res, err := m.Collection.FindOneAndUpdate(ctx, filter, update, opts...)
 	if err != nil {
 	if err != nil {

+ 8 - 8
core/stores/monc/cachedmodel.go

@@ -192,7 +192,7 @@ func (mm *Model) InsertOneNoCache(ctx context.Context, document interface{},
 }
 }
 
 
 // ReplaceOne replaces a single document in the collection, and remove the cache.
 // ReplaceOne replaces a single document in the collection, and remove the cache.
-func (mm *Model) ReplaceOne(ctx context.Context, key string, filter interface{}, replacement interface{},
+func (mm *Model) ReplaceOne(ctx context.Context, key string, filter, replacement interface{},
 	opts ...*mopt.ReplaceOptions) (*mongo.UpdateResult, error) {
 	opts ...*mopt.ReplaceOptions) (*mongo.UpdateResult, error) {
 	res, err := mm.Model.ReplaceOne(ctx, filter, replacement, opts...)
 	res, err := mm.Model.ReplaceOne(ctx, filter, replacement, opts...)
 	if err != nil {
 	if err != nil {
@@ -207,7 +207,7 @@ func (mm *Model) ReplaceOne(ctx context.Context, key string, filter interface{},
 }
 }
 
 
 // ReplaceOneNoCache replaces a single document in the collection.
 // ReplaceOneNoCache replaces a single document in the collection.
-func (mm *Model) ReplaceOneNoCache(ctx context.Context, filter interface{}, replacement interface{},
+func (mm *Model) ReplaceOneNoCache(ctx context.Context, filter, replacement interface{},
 	opts ...*mopt.ReplaceOptions) (*mongo.UpdateResult, error) {
 	opts ...*mopt.ReplaceOptions) (*mongo.UpdateResult, error) {
 	return mm.Model.ReplaceOne(ctx, filter, replacement, opts...)
 	return mm.Model.ReplaceOne(ctx, filter, replacement, opts...)
 }
 }
@@ -218,7 +218,7 @@ func (mm *Model) SetCache(key string, v interface{}) error {
 }
 }
 
 
 // UpdateByID updates the document with given id with update, and remove the cache.
 // UpdateByID updates the document with given id with update, and remove the cache.
-func (mm *Model) UpdateByID(ctx context.Context, key string, id interface{}, update interface{},
+func (mm *Model) UpdateByID(ctx context.Context, key string, id, update interface{},
 	opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) {
 	opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) {
 	res, err := mm.Model.UpdateByID(ctx, id, update, opts...)
 	res, err := mm.Model.UpdateByID(ctx, id, update, opts...)
 	if err != nil {
 	if err != nil {
@@ -233,13 +233,13 @@ func (mm *Model) UpdateByID(ctx context.Context, key string, id interface{}, upd
 }
 }
 
 
 // UpdateByIDNoCache updates the document with given id with update.
 // UpdateByIDNoCache updates the document with given id with update.
-func (mm *Model) UpdateByIDNoCache(ctx context.Context, id interface{}, update interface{},
+func (mm *Model) UpdateByIDNoCache(ctx context.Context, id, update interface{},
 	opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) {
 	opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) {
 	return mm.Model.UpdateByID(ctx, id, update, opts...)
 	return mm.Model.UpdateByID(ctx, id, update, opts...)
 }
 }
 
 
 // UpdateMany updates the documents that match filter with update, and remove the cache.
 // UpdateMany updates the documents that match filter with update, and remove the cache.
-func (mm *Model) UpdateMany(ctx context.Context, keys []string, filter interface{}, update interface{},
+func (mm *Model) UpdateMany(ctx context.Context, keys []string, filter, update interface{},
 	opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) {
 	opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) {
 	res, err := mm.Model.UpdateMany(ctx, filter, update, opts...)
 	res, err := mm.Model.UpdateMany(ctx, filter, update, opts...)
 	if err != nil {
 	if err != nil {
@@ -254,13 +254,13 @@ func (mm *Model) UpdateMany(ctx context.Context, keys []string, filter interface
 }
 }
 
 
 // UpdateManyNoCache updates the documents that match filter with update.
 // UpdateManyNoCache updates the documents that match filter with update.
-func (mm *Model) UpdateManyNoCache(ctx context.Context, filter interface{}, update interface{},
+func (mm *Model) UpdateManyNoCache(ctx context.Context, filter, update interface{},
 	opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) {
 	opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) {
 	return mm.Model.UpdateMany(ctx, filter, update, opts...)
 	return mm.Model.UpdateMany(ctx, filter, update, opts...)
 }
 }
 
 
 // UpdateOne updates the first document that matches filter with update, and remove the cache.
 // UpdateOne updates the first document that matches filter with update, and remove the cache.
-func (mm *Model) UpdateOne(ctx context.Context, key string, filter interface{}, update interface{},
+func (mm *Model) UpdateOne(ctx context.Context, key string, filter, update interface{},
 	opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) {
 	opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) {
 	res, err := mm.Model.UpdateOne(ctx, filter, update, opts...)
 	res, err := mm.Model.UpdateOne(ctx, filter, update, opts...)
 	if err != nil {
 	if err != nil {
@@ -275,7 +275,7 @@ func (mm *Model) UpdateOne(ctx context.Context, key string, filter interface{},
 }
 }
 
 
 // UpdateOneNoCache updates the first document that matches filter with update.
 // UpdateOneNoCache updates the first document that matches filter with update.
-func (mm *Model) UpdateOneNoCache(ctx context.Context, filter interface{}, update interface{},
+func (mm *Model) UpdateOneNoCache(ctx context.Context, filter, update interface{},
 	opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) {
 	opts ...*mopt.UpdateOptions) (*mongo.UpdateResult, error) {
 	return mm.Model.UpdateOne(ctx, filter, update, opts...)
 	return mm.Model.UpdateOne(ctx, filter, update, opts...)
 }
 }

+ 1 - 1
tools/goctl/api/docgen/doc.go

@@ -107,7 +107,7 @@ func associatedTypes(tp spec.DefineStruct, tps *[]spec.Type) {
 }
 }
 
 
 // buildTypes gen types to string
 // buildTypes gen types to string
-func buildTypes(types []spec.Type, all []spec.Type) (string, error) {
+func buildTypes(types, all []spec.Type) (string, error) {
 	var builder strings.Builder
 	var builder strings.Builder
 	first := true
 	first := true
 	for _, tp := range types {
 	for _, tp := range types {