diff --git a/githooks/pre-commit/fmt b/githooks/pre-commit/fmt index 3a477f090c..144c5ca916 100755 --- a/githooks/pre-commit/fmt +++ b/githooks/pre-commit/fmt @@ -1,5 +1,9 @@ #! /bin/bash -export GO_DIFF_FILES=$(git diff --name-only --diff-filter=d HEAD "*.go") +GO_DIFF_FILES="" + +while read -r line; do + export GO_DIFF_FILES="$GO_DIFF_FILES $line" +done <<< "$(git diff --name-only --diff-filter=d HEAD "*.go")" make fmt diff --git a/internal/master/master.go b/internal/master/master.go index 5476a7c8dc..90093cc22e 100644 --- a/internal/master/master.go +++ b/internal/master/master.go @@ -181,7 +181,7 @@ func CreateServer(ctx context.Context) (*Master, error) { m.scheduler.SetDDMsgStream(pulsarDDStream) m.scheduler.SetIDAllocator(func() (UniqueID, error) { return m.idAllocator.AllocOne() }) - flushClient, err := writerclient.NewWriterClient(Params.EtcdAddress, Params.MetaRootPath, Params.WriteNodeSegKvSubPath, pulsarDDStream) + flushClient, err := writerclient.NewWriterClient(Params.EtcdAddress, kvRootPath, Params.WriteNodeSegKvSubPath, pulsarDDStream) if err != nil { return nil, err } diff --git a/internal/storage/print_binlog.go b/internal/storage/print_binlog.go index a28edd28f5..f8eb92e21e 100644 --- a/internal/storage/print_binlog.go +++ b/internal/storage/print_binlog.go @@ -310,28 +310,32 @@ func printDDLPayloadValues(eventType EventTypeCode, colType schemapb.DataType, r switch eventType { case CreateCollectionEventType: var req internalpb.CreateCollectionRequest - if err := proto.UnmarshalText(val, &req); err != nil { + if err := proto.Unmarshal(([]byte)(val), &req); err != nil { return err } - fmt.Printf("\t\t%d : create collection: %v\n", i, req) + msg := proto.MarshalTextString(&req) + fmt.Printf("\t\t%d : create collection: %s\n", i, msg) case DropCollectionEventType: - var req internalpb.DropCollectionRequest - if err := proto.UnmarshalText(val, &req); err != nil { + var req internalpb.DropPartitionRequest + if err := proto.Unmarshal(([]byte)(val), &req); err != nil { return err } - fmt.Printf("\t\t%d : drop collection: %v\n", i, req) + msg := proto.MarshalTextString(&req) + fmt.Printf("\t\t%d : drop collection: %s\n", i, msg) case CreatePartitionEventType: var req internalpb.CreatePartitionRequest - if err := proto.UnmarshalText(val, &req); err != nil { + if err := proto.Unmarshal(([]byte)(val), &req); err != nil { return err } - fmt.Printf("\t\t%d : create partition: %v\n", i, req) + msg := proto.MarshalTextString(&req) + fmt.Printf("\t\t%d : create partition: %s\n", i, msg) case DropPartitionEventType: var req internalpb.DropPartitionRequest - if err := proto.UnmarshalText(val, &req); err != nil { + if err := proto.Unmarshal(([]byte)(val), &req); err != nil { return err } - fmt.Printf("\t\t%d : drop partition: %v\n", i, req) + msg := proto.MarshalTextString(&req) + fmt.Printf("\t\t%d : drop partition: %s\n", i, msg) default: return errors.Errorf("undefined ddl event type %d", eventType) } diff --git a/internal/writenode/flow_graph_insert_buffer_node.go b/internal/writenode/flow_graph_insert_buffer_node.go index 0c001ee55d..bf6180d269 100644 --- a/internal/writenode/flow_graph_insert_buffer_node.go +++ b/internal/writenode/flow_graph_insert_buffer_node.go @@ -542,21 +542,15 @@ func (ibNode *insertBufferNode) getMeta(segID UniqueID) (*etcdpb.SegmentMeta, *e segMeta := &etcdpb.SegmentMeta{} key := path.Join(SegmentPrefix, strconv.FormatInt(segID, 10)) - value, err := ibNode.kvClient.Load(key) - if err != nil { - return nil, nil, err - } - err = proto.UnmarshalText(value, segMeta) + value, _ := ibNode.kvClient.Load(key) + err := proto.UnmarshalText(value, segMeta) if err != nil { return nil, nil, err } collMeta := &etcdpb.CollectionMeta{} key = path.Join(CollectionPrefix, strconv.FormatInt(segMeta.GetCollectionID(), 10)) - value, err = ibNode.kvClient.Load(key) - if err != nil { - return nil, nil, err - } + value, _ = ibNode.kvClient.Load(key) err = proto.UnmarshalText(value, collMeta) if err != nil { return nil, nil, err diff --git a/scripts/gofmt.sh b/scripts/gofmt.sh index 24a974477f..99dd999bf8 100755 --- a/scripts/gofmt.sh +++ b/scripts/gofmt.sh @@ -13,13 +13,16 @@ function bred(){ files=() files_need_gofmt=() -if [ -f "$1" ];then - files+=("$1") -fi - -if [ -d "$1" ];then - for file in `find $1 -type f | grep "\.go$"`; do - files+=("$file") +if [[ $# -ne 0 ]]; then + for arg in "$@"; do + if [ -f "$arg" ];then + files+=("$arg") + fi + if [ -d "$arg" ];then + for file in `find $arg -type f | grep "\.go$"`; do + files+=("$file") + done + fi done fi