Fix go format bug

Signed-off-by: quicksilver <zhifeng.zhang@zilliz.com>
This commit is contained in:
quicksilver 2021-01-05 14:20:45 +08:00 committed by yefu.chen
parent 8b39643e44
commit ca89ece576
5 changed files with 32 additions and 27 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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)
}

View File

@ -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

View File

@ -13,15 +13,18 @@ function bred(){
files=()
files_need_gofmt=()
if [ -f "$1" ];then
files+=("$1")
if [[ $# -ne 0 ]]; then
for arg in "$@"; do
if [ -f "$arg" ];then
files+=("$arg")
fi
if [ -d "$1" ];then
for file in `find $1 -type f | grep "\.go$"`; do
if [ -d "$arg" ];then
for file in `find $arg -type f | grep "\.go$"`; do
files+=("$file")
done
fi
done
fi
# Check for files that fail gofmt.
if [[ "${#files[@]}" -ne 0 ]]; then