Repository: milvus-io/milvus-sdk-go
Pull request #293 (2022-07-20 13:16:06)

Fix lint issue reported by golangci-lint
Related to #292 

/kind improvement

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>

sre-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/milvus-io/milvus-sdk-go/pull/293#" title="Author self-approved">congqixia</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=milvus-io%2Fmilvus-sdk-go).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/milvus-io/milvus-sdk-go/blob/master/OWNERS)~~ [congqixia]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
codecov[bot]: # [Codecov](https://codecov.io/gh/milvus-io/milvus-sdk-go/pull/293?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=milvus-io) Report
> Merging [#293](https://codecov.io/gh/milvus-io/milvus-sdk-go/pull/293?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=milvus-io) (887eef5) into [master](https://codecov.io/gh/milvus-io/milvus-sdk-go/commit/2b001222228ff6e477dc451e554a96df29892e4e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=milvus-io) (2b00122) will **increase** coverage by `0.03%`.
> The diff coverage is `92.00%`.

[![Impacted file tree graph](https://codecov.io/gh/milvus-io/milvus-sdk-go/pull/293/graphs/tree.svg?width=650&height=150&src=pr&token=WJK43PV390&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=milvus-io)](https://codecov.io/gh/milvus-io/milvus-sdk-go/pull/293?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=milvus-io)

```diff
@@            Coverage Diff             @@
##           master     #293      +/-   ##
==========================================
+ Coverage   90.19%   90.22%   +0.03%     
==========================================
  Files          24       24              
  Lines        2662     2661       -1     
==========================================
  Hits         2401     2401              
+ Misses        178      177       -1     
  Partials       83       83              
```


| [Impacted Files](https://codecov.io/gh/milvus-io/milvus-sdk-go/pull/293?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=milvus-io) | Coverage Δ | |
|---|---|---|
| [client/client\_grpc\_authentication.go](https://codecov.io/gh/milvus-io/milvus-sdk-go/pull/293/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=milvus-io#diff-Y2xpZW50L2NsaWVudF9ncnBjX2F1dGhlbnRpY2F0aW9uLmdv) | `100.00% <ø> (ø)` | |
| [client/client\_grpc\_row.go](https://codecov.io/gh/milvus-io/milvus-sdk-go/pull/293/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=milvus-io#diff-Y2xpZW50L2NsaWVudF9ncnBjX3Jvdy5nbw==) | `83.48% <ø> (+0.38%)` | :arrow_up: |
| [client/interceptor.go](https://codecov.io/gh/milvus-io/milvus-sdk-go/pull/293/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=milvus-io#diff-Y2xpZW50L2ludGVyY2VwdG9yLmdv) | `25.00% <ø> (ø)` | |
| [entity/columns\_varchar.go](https://codecov.io/gh/milvus-io/milvus-sdk-go/pull/293/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=milvus-io#diff-ZW50aXR5L2NvbHVtbnNfdmFyY2hhci5nbw==) | `100.00% <ø> (ø)` | |
| [entity/schema.go](https://codecov.io/gh/milvus-io/milvus-sdk-go/pull/293/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=milvus-io#diff-ZW50aXR5L3NjaGVtYS5nbw==) | `93.10% <ø> (ø)` | |
| [client/client\_grpc\_data.go](https://codecov.io/gh/milvus-io/milvus-sdk-go/pull/293/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=milvus-io#diff-Y2xpZW50L2NsaWVudF9ncnBjX2RhdGEuZ28=) | `76.85% <71.42%> (ø)` | |
| [client/client\_grpc\_control.go](https://codecov.io/gh/milvus-io/milvus-sdk-go/pull/293/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=milvus-io#diff-Y2xpZW50L2NsaWVudF9ncnBjX2NvbnRyb2wuZ28=) | `95.55% <100.00%> (ø)` | |
| [client/client\_grpc\_options.go](https://codecov.io/gh/milvus-io/milvus-sdk-go/pull/293/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=milvus-io#diff-Y2xpZW50L2NsaWVudF9ncnBjX29wdGlvbnMuZ28=) | `100.00% <100.00%> (ø)` | |
| [entity/rows.go](https://codecov.io/gh/milvus-io/milvus-sdk-go/pull/293/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=milvus-io#diff-ZW50aXR5L3Jvd3MuZ28=) | `91.97% <100.00%> (ø)` | |

congqixia: /cc @letian-jiang 

Patch:
diff --git a/.golangci.yml b/.golangci.yml
index 06a3d73..000d540 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -21,9 +21,9 @@ linters:
     - goimports
     - misspell
     - govet
-    - golint
     - ineffassign
     - gosimple
+    - revive
 
 issues:
   exclude-use-default: false
@@ -33,6 +33,10 @@ issues:
     - should be of the form
     - should not use dot imports
     - which can be annoying to use
+  # Maximum issue count per one linter. Set to 0 to disable. Default is 50.
+  max-issues-per-linter: 0
+  # Maximum count of issues with same text. Set to 0 to disable. Default is 3.
+  max-same-issues: 0
 service:
   golangci-lint-version: 1.27.0 # use the fixed version to not introduce new linters unexpectedly
 
diff --git a/client/client_grpc_authentication.go b/client/client_grpc_authentication.go
index fc7b349..17b7ca0 100644
--- a/client/client_grpc_authentication.go
+++ b/client/client_grpc_authentication.go
@@ -2,6 +2,7 @@ package client
 
 import (
 	"context"
+
 	"github.com/milvus-io/milvus-sdk-go/v2/internal/proto/server"
 	"github.com/milvus-io/milvus-sdk-go/v2/internal/utils/crypto"
 )
diff --git a/client/client_grpc_control.go b/client/client_grpc_control.go
index 9d78411..5458669 100644
--- a/client/client_grpc_control.go
+++ b/client/client_grpc_control.go
@@ -62,18 +62,18 @@ func (c *grpcClient) ManualCompaction(ctx context.Context, collName string, tole
 // GetCompactionState get compaction state of provided compaction id
 func (c *grpcClient) GetCompactionState(ctx context.Context, id int64) (entity.CompactionState, error) {
 	if c.service == nil {
-		return entity.COMPACTION_STATE_UNDEFINED, ErrClientNotReady
+		return entity.CompcationStateUndefined, ErrClientNotReady
 	}
 
 	req := &server.GetCompactionStateRequest{CompactionID: id}
 	resp, err := c.service.GetCompactionState(ctx, req)
 	if err != nil {
-		return entity.COMPACTION_STATE_UNDEFINED, err
+		return entity.CompcationStateUndefined, err
 	}
 
 	err = handleRespStatus(resp.GetStatus())
 	if err != nil {
-		return entity.COMPACTION_STATE_UNDEFINED, err
+		return entity.CompcationStateUndefined, err
 	}
 
 	// direct mapping values of CompactionState
@@ -83,7 +83,7 @@ func (c *grpcClient) GetCompactionState(ctx context.Context, id int64) (entity.C
 // GetCompactionStateWithPlans get compaction state with plans of provided compaction id
 func (c *grpcClient) GetCompactionStateWithPlans(ctx context.Context, id int64) (entity.CompactionState, []entity.CompactionPlan, error) {
 	if c.service == nil {
-		return entity.COMPACTION_STATE_UNDEFINED, nil, ErrClientNotReady
+		return entity.CompcationStateUndefined, nil, ErrClientNotReady
 	}
 
 	req := &server.GetCompactionPlansRequest{
@@ -91,12 +91,12 @@ func (c *grpcClient) GetCompactionStateWithPlans(ctx context.Context, id int64)
 	}
 	resp, err := c.service.GetCompactionStateWithPlans(ctx, req)
 	if err != nil {
-		return entity.COMPACTION_STATE_UNDEFINED, nil, err
+		return entity.CompcationStateUndefined, nil, err
 	}
 
 	err = handleRespStatus(resp.GetStatus())
 	if err != nil {
-		return entity.COMPACTION_STATE_UNDEFINED, nil, err
+		return entity.CompcationStateUndefined, nil, err
 	}
 
 	plans := make([]entity.CompactionPlan, 0, len(resp.GetMergeInfos()))
@@ -104,7 +104,7 @@ func (c *grpcClient) GetCompactionStateWithPlans(ctx context.Context, id int64)
 		plans = append(plans, entity.CompactionPlan{
 			Source:   mergeInfo.GetSources(),
 			Target:   mergeInfo.GetTarget(),
-			PlanType: entity.COMPACTION_PLAN_MERGE_SEGMENTS,
+			PlanType: entity.CompactionPlanMergeSegments,
 		})
 	}
 
diff --git a/client/client_grpc_data.go b/client/client_grpc_data.go
index 403f579..534f7e4 100644
--- a/client/client_grpc_data.go
+++ b/client/client_grpc_data.go
@@ -85,8 +85,8 @@ func (c *grpcClient) Insert(ctx context.Context, collName string, partitionName
 			case *entity.ColumnBinaryVector:
 				dim = column.Dim()
 			}
-			if fmt.Sprintf("%d", dim) != field.TypeParams[entity.TYPE_PARAM_DIM] {
-				return nil, fmt.Errorf("params column %s vector dim %d not match collection definition, which has dim of %s", field.Name, dim, field.TypeParams[entity.TYPE_PARAM_DIM])
+			if fmt.Sprintf("%d", dim) != field.TypeParams[entity.TypeParamDim] {
+				return nil, fmt.Errorf("params column %s vector dim %d not match collection definition, which has dim of %s", field.Name, dim, field.TypeParams[entity.TypeParamDim])
 			}
 		}
 	}
@@ -264,7 +264,7 @@ func (c *grpcClient) Search(ctx context.Context, collName string, partitions []s
 	if !has {
 		return nil, fmt.Errorf("vector field %s does not exist in collection %s", vectorField, collName)
 	}
-	dimStr := vfDef.TypeParams[entity.TYPE_PARAM_DIM]
+	dimStr := vfDef.TypeParams[entity.TypeParamDim]
 	for _, vector := range vectors {
 		if fmt.Sprintf("%d", vector.Dim()) != dimStr {
 			return nil, fmt.Errorf("vector %s has dim of %s while found search vector with dim %d", vectorField,
@@ -758,17 +758,17 @@ func estRowSize(sch *entity.Schema, selected []string) int64 {
 		case entity.FieldTypeString:
 			// TODO string need varchar[max] syntax like limitation
 		case entity.FieldTypeVarChar:
-			maxLength, err := strconv.Atoi(field.TypeParams[entity.TYPE_PARAM_MAX_LENGTH])
+			maxLength, err := strconv.Atoi(field.TypeParams[entity.TypeParamMaxLength])
 			if err != nil {
-				log.Fatalf("got invalid varchar max length = %s", field.TypeParams[entity.TYPE_PARAM_MAX_LENGTH])
+				log.Fatalf("got invalid varchar max length = %s", field.TypeParams[entity.TypeParamMaxLength])
 			}
 			total += int64(maxLength)
 		case entity.FieldTypeFloatVector:
-			dimStr := field.TypeParams[entity.TYPE_PARAM_DIM]
+			dimStr := field.TypeParams[entity.TypeParamDim]
 			dim, _ := strconv.ParseInt(dimStr, 10, 64)
 			total += 4 * dim
 		case entity.FieldTypeBinaryVector:
-			dimStr := field.TypeParams[entity.TYPE_PARAM_DIM]
+			dimStr := field.TypeParams[entity.TypeParamDim]
 			dim, _ := strconv.ParseInt(dimStr, 10, 64)
 			total += 4 * dim / 8
 		}
diff --git a/client/client_grpc_options.go b/client/client_grpc_options.go
index e83ec13..6c86812 100644
--- a/client/client_grpc_options.go
+++ b/client/client_grpc_options.go
@@ -13,6 +13,7 @@ package client
 
 import (
 	"errors"
+
 	"github.com/milvus-io/milvus-sdk-go/v2/entity"
 	server "github.com/milvus-io/milvus-sdk-go/v2/internal/proto/server"
 )
@@ -77,24 +78,24 @@ func MakeSearchQueryOption(c *entity.Collection, opts ...SearchQueryOptionFunc)
 	}
 
 	// sanity-check
-	if opt.ConsistencyLevel != entity.CL_CUSTOMIZED && opt.GuaranteeTimestamp != 0 {
+	if opt.ConsistencyLevel != entity.ClCustomized && opt.GuaranteeTimestamp != 0 {
 		return nil, errors.New("user can only specify guarantee timestamp under customized consistency level")
 	}
 
 	switch opt.ConsistencyLevel {
-	case entity.CL_STRONG:
+	case entity.ClStrong:
 		opt.GuaranteeTimestamp = StrongTimestamp
-	case entity.CL_SESSION:
+	case entity.ClSession:
 		ts, ok := tsm.get(c.ID)
 		if !ok {
 			ts = EventuallyTimestamp
 		}
 		opt.GuaranteeTimestamp = ts
-	case entity.CL_BOUNDED:
+	case entity.ClBounded:
 		opt.GuaranteeTimestamp = BoundedTimestamp
-	case entity.CL_EVENTUALLY:
+	case entity.ClEventually:
 		opt.GuaranteeTimestamp = EventuallyTimestamp
-	case entity.CL_CUSTOMIZED:
+	case entity.ClCustomized:
 		// respect opt.GuaranteeTimestamp
 	}
 	return opt, nil
diff --git a/client/client_grpc_row.go b/client/client_grpc_row.go
index 058769d..a3f8259 100644
--- a/client/client_grpc_row.go
+++ b/client/client_grpc_row.go
@@ -166,7 +166,6 @@ func SearchResultToRows(sch *entity.Schema, results *schema.SearchResultData, t
 						f.SetString(strIds.GetData()[offset+j])
 					default:
 						entry.Err = fmt.Errorf("field %s is not valid primary key", field.Name)
-						break
 					}
 					continue
 				}
diff --git a/client/interceptor.go b/client/interceptor.go
index 59f7f55..1aa8b1c 100644
--- a/client/interceptor.go
+++ b/client/interceptor.go
@@ -3,6 +3,7 @@ package client
 import (
 	"context"
 	"fmt"
+
 	"github.com/milvus-io/milvus-sdk-go/v2/internal/utils/crypto"
 	"google.golang.org/grpc"
 	"google.golang.org/grpc/metadata"
diff --git a/entity/columns_varchar.go b/entity/columns_varchar.go
index ae410af..626258e 100644
--- a/entity/columns_varchar.go
+++ b/entity/columns_varchar.go
@@ -3,6 +3,7 @@ package entity
 import (
 	"errors"
 	"fmt"
+
 	"github.com/milvus-io/milvus-sdk-go/v2/internal/proto/schema"
 )
 
diff --git a/entity/compaction.go b/entity/compaction.go
index aa77053..3b1b55e 100644
--- a/entity/compaction.go
+++ b/entity/compaction.go
@@ -21,24 +21,24 @@ package entity
 type CompactionState int32
 
 const (
-	//COMPACTION_STATE_UNDEFINED zero value placeholder
-	COMPACTION_STATE_UNDEFINED CompactionState = 0
-	//COMPACTION_STATE_EXECUTING compaction in progress
-	COMPACTION_STATE_EXECUTING CompactionState = 1
-	// COMPACTION_STATE_COMPLETED compcation done
-	COMPACTION_STATE_COMPLETED CompactionState = 2
+	//CompcationStateUndefined zero value placeholder
+	CompcationStateUndefined CompactionState = 0
+	//CompactionStateExecuting compaction in progress
+	CompactionStateExecuting CompactionState = 1
+	// CompactionStateCompleted compcation done
+	CompactionStateCompleted CompactionState = 2
 )
 
 type CompactionPlanType int32
 
 // See https://wiki.lfaidata.foundation/display/MIL/MEP+16+--+Compaction
 const (
-	// COMPACTION_PLAN_UNDEFINE zero value placeholder
-	COMPACTION_PLAN_UNDEFINE CompactionPlanType = 0
-	// COMPACTION_PLAN_APPLY_DELETE apply delete log
-	COMPACTION_PLAN_APPLY_DELETE CompactionPlanType = 1
-	// COMPACTION_PLAN_MERGE_SEGMENTS merge multiple segments
-	COMPACTION_PLAN_MERGE_SEGMENTS CompactionPlanType = 2
+	// CompactionPlanUndefined zero value placeholder
+	CompactionPlanUndefined CompactionPlanType = 0
+	// CompactionPlanApplyDelete apply delete log
+	CompactionPlanApplyDelete CompactionPlanType = 1
+	// CompactionPlanMergeSegments merge multiple segments
+	CompactionPlanMergeSegments CompactionPlanType = 2
 )
 
 // CompactionMergePlan contains compaction plan of merging multple segments
diff --git a/entity/rows.go b/entity/rows.go
index c07e33b..8e06726 100644
--- a/entity/rows.go
+++ b/entity/rows.go
@@ -142,12 +142,12 @@ func ParseSchema(r Row) (*Schema, error) {
 				field.DataType = FieldTypeBinaryVector
 				//TODO maybe override by tag settings, when dim is not multiplier of 8
 				field.TypeParams = map[string]string{
-					TYPE_PARAM_DIM: strconv.FormatInt(int64(arrayLen*8), 10),
+					TypeParamDim: strconv.FormatInt(int64(arrayLen*8), 10),
 				}
 			case reflect.Float32:
 				field.DataType = FieldTypeFloatVector
 				field.TypeParams = map[string]string{
-					TYPE_PARAM_DIM: strconv.FormatInt(int64(arrayLen), 10),
+					TypeParamDim: strconv.FormatInt(int64(arrayLen), 10),
 				}
 			default:
 				return nil, fmt.Errorf("field %s is array of %v, which is not supported", f.Name, elemType)
@@ -165,7 +165,7 @@ func ParseSchema(r Row) (*Schema, error) {
 				return nil, fmt.Errorf("dim value %d is out of range", dim)
 			}
 			field.TypeParams = map[string]string{
-				TYPE_PARAM_DIM: dimStr,
+				TypeParamDim: dimStr,
 			}
 			elemType := ft.Elem()
 			switch elemType.Kind() {
@@ -273,7 +273,7 @@ func RowsToColumns(rows []Row, schemas ...*Schema) ([]Column, error) {
 			nameColumns[field.Name] = col
 		case FieldTypeFloatVector:
 			data := make([][]float32, 0, rowsLen)
-			dimStr, has := field.TypeParams[TYPE_PARAM_DIM]
+			dimStr, has := field.TypeParams[TypeParamDim]
 			if !has {
 				return []Column{}, errors.New("vector field with no dim")
 			}
@@ -285,7 +285,7 @@ func RowsToColumns(rows []Row, schemas ...*Schema) ([]Column, error) {
 			nameColumns[field.Name] = col
 		case FieldTypeBinaryVector:
 			data := make([][]byte, 0, rowsLen)
-			dimStr, has := field.TypeParams[TYPE_PARAM_DIM]
+			dimStr, has := field.TypeParams[TypeParamDim]
 			if !has {
 				return []Column{}, errors.New("vector field with no dim")
 			}
diff --git a/entity/schema.go b/entity/schema.go
index 1310d57..d3e776a 100644
--- a/entity/schema.go
+++ b/entity/schema.go
@@ -17,22 +17,22 @@ import (
 )
 
 const (
-	// TYPE_PARAM_DIM is the const for field type param dimension
-	TYPE_PARAM_DIM = "dim"
+	// TypeParamDim is the const for field type param dimension
+	TypeParamDim = "dim"
 
-	// TYPE_PARAM_MAX_LENGTH is the const for varchar type maximal length
-	TYPE_PARAM_MAX_LENGTH = "max_length"
+	// TypeParamMaxLength is the const for varchar type maximal length
+	TypeParamMaxLength = "max_length"
 
-	// CL_STRONG strong consistency level
-	CL_STRONG ConsistencyLevel = ConsistencyLevel(common.ConsistencyLevel_Strong)
-	// CL_BOUNDED bounded consistency level with default tolerance of 5 seconds
-	CL_BOUNDED ConsistencyLevel = ConsistencyLevel(common.ConsistencyLevel_Bounded)
-	// CL_SESSION session consistency level
-	CL_SESSION ConsistencyLevel = ConsistencyLevel(common.ConsistencyLevel_Session)
-	// CL_EVENTUALLY eventually consistency level
-	CL_EVENTUALLY ConsistencyLevel = ConsistencyLevel(common.ConsistencyLevel_Eventually)
-	// CL_CUSTOMIZED customized consistency level and users pass their own `guarantee_timestamp`.
-	CL_CUSTOMIZED ConsistencyLevel = ConsistencyLevel(common.ConsistencyLevel_Customized)
+	// ClStrong strong consistency level
+	ClStrong ConsistencyLevel = ConsistencyLevel(common.ConsistencyLevel_Strong)
+	// ClBounded bounded consistency level with default tolerance of 5 seconds
+	ClBounded ConsistencyLevel = ConsistencyLevel(common.ConsistencyLevel_Bounded)
+	// ClSession session consistency level
+	ClSession ConsistencyLevel = ConsistencyLevel(common.ConsistencyLevel_Session)
+	// ClEvenually eventually consistency level
+	ClEventually ConsistencyLevel = ConsistencyLevel(common.ConsistencyLevel_Eventually)
+	// ClCustomized customized consistency level and users pass their own `guarantee_timestamp`.
+	ClCustomized ConsistencyLevel = ConsistencyLevel(common.ConsistencyLevel_Customized)
 )
 
 // ConsistencyLevel enum type for collection Consistency Level
diff --git a/entity/until_fail.sh b/entity/until_fail.sh
new file mode 100755
index 0000000..c2336c5
--- /dev/null
+++ b/entity/until_fail.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+$@
+while [[ $? -eq 0 ]]; do
+    $@
+done
diff --git a/examples/auth/auth.go b/examples/auth/auth.go
index 0a416c6..aea71b3 100644
--- a/examples/auth/auth.go
+++ b/examples/auth/auth.go
@@ -4,13 +4,14 @@ import (
 	"context"
 	"encoding/csv"
 	"fmt"
-	"github.com/milvus-io/milvus-sdk-go/v2/client"
-	"github.com/milvus-io/milvus-sdk-go/v2/entity"
-	"google.golang.org/grpc"
 	"log"
 	"os"
 	"strconv"
 	"strings"
+
+	"github.com/milvus-io/milvus-sdk-go/v2/client"
+	"github.com/milvus-io/milvus-sdk-go/v2/entity"
+	"google.golang.org/grpc"
 )
 
 const (
@@ -84,7 +85,7 @@ func main() {
 				Name:     "Vector",
 				DataType: entity.FieldTypeFloatVector,
 				TypeParams: map[string]string{
-					entity.TYPE_PARAM_DIM: "8",
+					entity.TypeParamDim: "8",
 				},
 			},
 		},
diff --git a/examples/basic/basic.go b/examples/basic/basic.go
index 061aa6a..0a732bd 100644
--- a/examples/basic/basic.go
+++ b/examples/basic/basic.go
@@ -56,7 +56,7 @@ func main() {
 				Name:     "vector",
 				DataType: entity.FieldTypeFloatVector,
 				TypeParams: map[string]string{ // the vector dim may changed def method in release
-					entity.TYPE_PARAM_DIM: "128",
+					entity.TypeParamDim: "128",
 				},
 			},
 		},
diff --git a/examples/calcdistance/calc_distance.go b/examples/calcdistance/calc_distance.go
index 6412bec..4e0a9f4 100644
--- a/examples/calcdistance/calc_distance.go
+++ b/examples/calcdistance/calc_distance.go
@@ -64,7 +64,7 @@ func main() {
 				Name:     "Vector",
 				DataType: entity.FieldTypeFloatVector,
 				TypeParams: map[string]string{
-					entity.TYPE_PARAM_DIM: "8",
+					entity.TypeParamDim: "8",
 				},
 			},
 		},
diff --git a/examples/hello_milvus/hello_milvus.go b/examples/hello_milvus/hello_milvus.go
index b66106d..c1ff983 100644
--- a/examples/hello_milvus/hello_milvus.go
+++ b/examples/hello_milvus/hello_milvus.go
@@ -63,7 +63,7 @@ func main() {
 				Name:     embeddingCol,
 				DataType: entity.FieldTypeFloatVector,
 				TypeParams: map[string]string{
-					entity.TYPE_PARAM_DIM: fmt.Sprintf("%d", dim),
+					entity.TypeParamDim: fmt.Sprintf("%d", dim),
 				},
 			},
 		},
diff --git a/examples/index/index.go b/examples/index/index.go
index 83aabd8..bfea4fb 100644
--- a/examples/index/index.go
+++ b/examples/index/index.go
@@ -65,7 +65,7 @@ func main() {
 				Name:     "Vector",
 				DataType: entity.FieldTypeFloatVector,
 				TypeParams: map[string]string{
-					entity.TYPE_PARAM_DIM: "8",
+					entity.TypeParamDim: "8",
 				},
 			},
 		},
diff --git a/examples/insert/insert.go b/examples/insert/insert.go
index 5d336ae..4d1d51a 100644
--- a/examples/insert/insert.go
+++ b/examples/insert/insert.go
@@ -65,7 +65,7 @@ func main() {
 				Name:     "Vector",
 				DataType: entity.FieldTypeFloatVector,
 				TypeParams: map[string]string{
-					entity.TYPE_PARAM_DIM: "8",
+					entity.TypeParamDim: "8",
 				},
 			},
 		},
diff --git a/examples/query/query.go b/examples/query/query.go
index dacb295..d5f5c34 100644
--- a/examples/query/query.go
+++ b/examples/query/query.go
@@ -63,14 +63,14 @@ func main() {
 				Name:     embeddingCol,
 				DataType: entity.FieldTypeFloatVector,
 				TypeParams: map[string]string{
-					entity.TYPE_PARAM_DIM: fmt.Sprintf("%d", dim),
+					entity.TypeParamDim: fmt.Sprintf("%d", dim),
 				},
 			},
 		},
 	}
 
 	// create collection with consistency level, which serves as the default search/query consistency level
-	if err := c.CreateCollection(ctx, schema, 2, client.WithConsistencyLevel(entity.CL_BOUNDED)); err != nil {
+	if err := c.CreateCollection(ctx, schema, 2, client.WithConsistencyLevel(entity.ClBounded)); err != nil {
 		log.Fatalf("create collection failed, err: %v", err)
 	}
 
@@ -144,7 +144,7 @@ func main() {
 	begin = time.Now()
 	sp, _ = entity.NewIndexFlatSearchParam(10)
 	sRet, err = c.Search(ctx, collectionName, nil, "", []string{randomCol}, vec2search,
-		embeddingCol, entity.L2, topK, sp, client.WithSearchQueryConsistencyLevel(entity.CL_STRONG))
+		embeddingCol, entity.L2, topK, sp, client.WithSearchQueryConsistencyLevel(entity.ClStrong)
 	end = time.Now()
 	if err != nil {
 		log.Fatalf("failed to search collection, err: %v", err)
diff --git a/examples/tls/tls.go b/examples/tls/tls.go
index f45d6c6..c93d0e2 100644
--- a/examples/tls/tls.go
+++ b/examples/tls/tls.go
@@ -93,7 +93,7 @@ func main() {
 				Name:     "Vector",
 				DataType: entity.FieldTypeFloatVector,
 				TypeParams: map[string]string{
-					entity.TYPE_PARAM_DIM: "8",
+					entity.TypeParamDim: "8",
 				},
 			},
 		},
diff --git a/examples/varchar/varchar_pk.go b/examples/varchar/varchar_pk.go
index 5aef0af..8a053b8 100644
--- a/examples/varchar/varchar_pk.go
+++ b/examples/varchar/varchar_pk.go
@@ -54,7 +54,7 @@ func main() {
 				PrimaryKey: true,
 				AutoID:     false,
 				TypeParams: map[string]string{
-					entity.TYPE_PARAM_MAX_LENGTH: fmt.Sprintf("%d", maxLength),
+					entity.TypeParamMaxLength: fmt.Sprintf("%d", maxLength),
 				},
 			},
 			{
@@ -67,7 +67,7 @@ func main() {
 				Name:     embeddingCol,
 				DataType: entity.FieldTypeFloatVector,
 				TypeParams: map[string]string{
-					entity.TYPE_PARAM_DIM: fmt.Sprintf("%d", dim),
+					entity.TypeParamDim: fmt.Sprintf("%d", dim),
 				},
 			},
 		},
@@ -103,7 +103,7 @@ func main() {
 	idColData := entity.NewColumnVarChar(idCol, idList)
 	randomColData := entity.NewColumnDouble(randomCol, randomList)
 	embeddingColData := entity.NewColumnFloatVector(embeddingCol, dim, embeddingList)
-	
+
 	if _, err := c.Insert(ctx, collectionName, "", idColData, randomColData, embeddingColData); err != nil {
 		log.Fatalf("failed to insert random data into `hello_milvus, err: %v", err)
 	}


Test patch:
diff --git a/client/client_grpc_authentication_test.go b/client/client_grpc_authentication_test.go
index ce8e276..d2cda9a 100644
--- a/client/client_grpc_authentication_test.go
+++ b/client/client_grpc_authentication_test.go
@@ -3,11 +3,12 @@ package client
 import (
 	"context"
 	"errors"
+	"testing"
+
 	"github.com/golang/protobuf/proto"
 	"github.com/milvus-io/milvus-sdk-go/v2/internal/proto/common"
 	"github.com/milvus-io/milvus-sdk-go/v2/internal/proto/server"
 	"github.com/stretchr/testify/assert"
-	"testing"
 )
 
 func TestGrpcClient_CreateCredential(t *testing.T) {
diff --git a/client/client_grpc_collection_test.go b/client/client_grpc_collection_test.go
index 0ae5f2e..210053f 100644
--- a/client/client_grpc_collection_test.go
+++ b/client/client_grpc_collection_test.go
@@ -133,7 +133,7 @@ func TestGrpcClientCreateCollection(t *testing.T) {
 
 			return &common.Status{ErrorCode: common.ErrorCode_Success}, nil
 		})
-		assert.Nil(t, c.CreateCollection(ctx, ds, shardsNum, WithConsistencyLevel(entity.CL_EVENTUALLY)))
+		assert.Nil(t, c.CreateCollection(ctx, ds, shardsNum, WithConsistencyLevel(entity.ClEventually)))
 		mock.delInjection(mCreateCollection)
 	})
 
@@ -156,7 +156,7 @@ func TestGrpcClientCreateCollection(t *testing.T) {
 					{
 						Name:       "vector",
 						DataType:   entity.FieldTypeFloatVector,
-						TypeParams: map[string]string{entity.TYPE_PARAM_DIM: "128"},
+						TypeParams: map[string]string{entity.TypeParamDim: "128"},
 					},
 				},
 			},
@@ -177,7 +177,7 @@ func TestGrpcClientCreateCollection(t *testing.T) {
 					{
 						Name:       "vector",
 						DataType:   entity.FieldTypeFloatVector,
-						TypeParams: map[string]string{entity.TYPE_PARAM_DIM: "128"},
+						TypeParams: map[string]string{entity.TypeParamDim: "128"},
 					},
 				},
 			},
@@ -200,7 +200,7 @@ func TestGrpcClientCreateCollection(t *testing.T) {
 					{
 						Name:       "vector",
 						DataType:   entity.FieldTypeFloatVector,
-						TypeParams: map[string]string{entity.TYPE_PARAM_DIM: "128"},
+						TypeParams: map[string]string{entity.TypeParamDim: "128"},
 					},
 				},
 			},
@@ -216,7 +216,7 @@ func TestGrpcClientCreateCollection(t *testing.T) {
 					{
 						Name:       "vector",
 						DataType:   entity.FieldTypeFloatVector,
-						TypeParams: map[string]string{entity.TYPE_PARAM_DIM: "128"},
+						TypeParams: map[string]string{entity.TypeParamDim: "128"},
 					},
 				},
 			},
@@ -359,7 +359,7 @@ func TestGrpcClientLoadCollection(t *testing.T) {
 			s, err := successStatus()
 			r.Status = s
 			r.CollectionIds = []int64{1}
-			var perc int64 = 0
+			var perc int64
 			if time.Since(start) > time.Duration(loadTime)*time.Millisecond {
 				t.Log("passed")
 				perc = 100
diff --git a/client/client_grpc_control_test.go b/client/client_grpc_control_test.go
index 01dbcac..7bae33c 100644
--- a/client/client_grpc_control_test.go
+++ b/client/client_grpc_control_test.go
@@ -142,12 +142,12 @@ func TestGrpcGetCompactionState(t *testing.T) {
 
 		result, err := c.GetCompactionState(ctx, compactionID)
 		assert.NoError(t, err)
-		assert.Equal(t, entity.COMPACTION_STATE_EXECUTING, result)
+		assert.Equal(t, entity.CompactionStateExecuting, result)
 
 		state = common.CompactionState_Completed
 		result, err = c.GetCompactionState(ctx, compactionID)
 		assert.NoError(t, err)
-		assert.Equal(t, entity.COMPACTION_STATE_COMPLETED, result)
+		assert.Equal(t, entity.CompactionStateCompleted, result)
 	})
 
 	t.Run("get compaction service fail", func(t *testing.T) {
@@ -175,8 +175,8 @@ func TestGrpcGetCompactionStateWithPlans(t *testing.T) {
 	t.Run("normal get compaction state with plans", func(t *testing.T) {
 		state := common.CompactionState_Executing
 		plans := []entity.CompactionPlan{
-			{Source: []int64{1, 2}, Target: 3, PlanType: entity.COMPACTION_PLAN_MERGE_SEGMENTS},
-			{Source: []int64{4, 5}, Target: 6, PlanType: entity.COMPACTION_PLAN_MERGE_SEGMENTS},
+			{Source: []int64{1, 2}, Target: 3, PlanType: entity.CompactionPlanMergeSegments},
+			{Source: []int64{4, 5}, Target: 6, PlanType: entity.CompactionPlanMergeSegments},
 		}
 
 		mock.setInjection(mGetCompactionStateWithPlans, func(_ context.Context, raw proto.Message) (proto.Message, error) {
@@ -206,13 +206,13 @@ func TestGrpcGetCompactionStateWithPlans(t *testing.T) {
 
 		result, rPlans, err := c.GetCompactionStateWithPlans(ctx, compactionID)
 		assert.NoError(t, err)
-		assert.Equal(t, entity.COMPACTION_STATE_EXECUTING, result)
+		assert.Equal(t, entity.CompactionStateExecuting, result)
 		assert.ElementsMatch(t, plans, rPlans)
 
 		state = common.CompactionState_Completed
 		result, rPlans, err = c.GetCompactionStateWithPlans(ctx, compactionID)
 		assert.NoError(t, err)
-		assert.Equal(t, entity.COMPACTION_STATE_COMPLETED, result)
+		assert.Equal(t, entity.CompactionStateCompleted, result)
 		assert.ElementsMatch(t, plans, rPlans)
 	})
 
diff --git a/client/client_grpc_data_test.go b/client/client_grpc_data_test.go
index 75ef71b..934bf71 100644
--- a/client/client_grpc_data_test.go
+++ b/client/client_grpc_data_test.go
@@ -309,7 +309,7 @@ func TestGrpcSearch(t *testing.T) {
 
 		// specify guarantee timestamp in strong consistency level
 		r, err = c.Search(ctx, testCollectionName, []string{}, "", []string{"int64"}, []entity.Vector{entity.FloatVector(vectors[0])}, "vector",
-			entity.HAMMING, 5, sp, WithSearchQueryConsistencyLevel(entity.CL_STRONG), WithGuaranteeTimestamp(1))
+			entity.HAMMING, 5, sp, WithSearchQueryConsistencyLevel(entity.ClStrong), WithGuaranteeTimestamp(1))
 		assert.Nil(t, r)
 		assert.NotNil(t, err)
 	})
@@ -378,13 +378,13 @@ func TestGrpcSearch(t *testing.T) {
 
 		// search with session consistency level
 		results, err = c.Search(ctx, testCollectionName, []string{}, expr, []string{"int64"}, []entity.Vector{entity.FloatVector(vectors[0])},
-			testVectorField, entity.L2, 10, sp, WithSearchQueryConsistencyLevel(entity.CL_SESSION), WithTravelTimestamp(0))
+			testVectorField, entity.L2, 10, sp, WithSearchQueryConsistencyLevel(entity.ClSession), WithTravelTimestamp(0))
 		assert.Nil(t, err)
 		assert.NotNil(t, results)
 
 		// search with customized consistency level
 		results, err = c.Search(ctx, testCollectionName, []string{}, expr, []string{"int64"}, []entity.Vector{entity.FloatVector(vectors[0])},
-			testVectorField, entity.L2, 10, sp, WithSearchQueryConsistencyLevel(entity.CL_CUSTOMIZED), WithTravelTimestamp(1))
+			testVectorField, entity.L2, 10, sp, WithSearchQueryConsistencyLevel(entity.ClCustomized), WithTravelTimestamp(1))
 		assert.Nil(t, err)
 		assert.NotNil(t, results)
 	})
@@ -459,7 +459,7 @@ func TestGrpcQueryByPks(t *testing.T) {
 		assert.ElementsMatch(t, []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, colInt64.Data())
 
 		// query with options
-		columns, err = c.QueryByPks(ctx, testCollectionName, []string{partName}, entity.NewColumnInt64(testPrimaryField, []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}), []string{"int64", testVectorField}, WithSearchQueryConsistencyLevel(entity.CL_SESSION), WithTravelTimestamp(0))
+		columns, err = c.QueryByPks(ctx, testCollectionName, []string{partName}, entity.NewColumnInt64(testPrimaryField, []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}), []string{"int64", testVectorField}, WithSearchQueryConsistencyLevel(entity.ClSession), WithTravelTimestamp(0))
 		assert.NoError(t, err)
 		assert.Equal(t, 2, len(columns))
 		assert.Equal(t, entity.FieldTypeInt64, columns[0].Type())
@@ -956,14 +956,14 @@ func TestEstRowSize(t *testing.T) {
 				Name:     testVectorField,
 				DataType: entity.FieldTypeFloatVector,
 				TypeParams: map[string]string{
-					entity.TYPE_PARAM_DIM: fmt.Sprintf("%d", testVectorDim),
+					entity.TypeParamDim: fmt.Sprintf("%d", testVectorDim),
 				},
 			},
 			{
 				Name:     "binary_vector",
 				DataType: entity.FieldTypeBinaryVector,
 				TypeParams: map[string]string{
-					entity.TYPE_PARAM_DIM: fmt.Sprintf("%d", testVectorDim),
+					entity.TypeParamDim: fmt.Sprintf("%d", testVectorDim),
 				},
 			},
 		},
diff --git a/client/client_grpc_options_test.go b/client/client_grpc_options_test.go
index c5def9f..3be080e 100644
--- a/client/client_grpc_options_test.go
+++ b/client/client_grpc_options_test.go
@@ -12,15 +12,16 @@
 package client
 
 import (
+	"testing"
+
 	"github.com/milvus-io/milvus-sdk-go/v2/entity"
 	"github.com/milvus-io/milvus-sdk-go/v2/internal/proto/common"
 	"github.com/milvus-io/milvus-sdk-go/v2/internal/proto/server"
 	"github.com/stretchr/testify/assert"
-	"testing"
 )
 
 func TestCreateCollectionWithConsistencyLevel(t *testing.T) {
-	opt := WithConsistencyLevel(entity.ConsistencyLevel(entity.CL_BOUNDED))
+	opt := WithConsistencyLevel(entity.ConsistencyLevel(entity.ClBounded))
 	assert.NotNil(t, opt)
 	req := &server.CreateCollectionRequest{}
 
@@ -46,7 +47,7 @@ func TestLoadCollectionWithReplicaNumber(t *testing.T) {
 func TestMakeSearchQueryOption(t *testing.T) {
 	c := &entity.Collection{
 		ID:               999,
-		ConsistencyLevel: entity.CL_STRONG,
+		ConsistencyLevel: entity.ClStrong,
 	}
 
 	t.Run("strong consistency", func(t *testing.T) {
@@ -54,68 +55,68 @@ func TestMakeSearchQueryOption(t *testing.T) {
 		assert.Nil(t, err)
 		assert.NotNil(t, opt)
 		expected := &SearchQueryOption{
-			ConsistencyLevel:   entity.CL_STRONG,
+			ConsistencyLevel:   entity.ClStrong,
 			GuaranteeTimestamp: StrongTimestamp,
 		}
 		assert.Equal(t, expected, opt)
 	})
 
 	t.Run("session consistency", func(t *testing.T) {
-		opt, err := MakeSearchQueryOption(c, WithSearchQueryConsistencyLevel(entity.CL_SESSION))
+		opt, err := MakeSearchQueryOption(c, WithSearchQueryConsistencyLevel(entity.ClSession))
 		assert.Nil(t, err)
 		assert.NotNil(t, opt)
 		expected := &SearchQueryOption{
-			ConsistencyLevel:   entity.CL_SESSION,
+			ConsistencyLevel:   entity.ClSession,
 			GuaranteeTimestamp: EventuallyTimestamp,
 		}
 		assert.Equal(t, expected, opt)
 
 		tsm.set(c.ID, 99)
-		opt, err = MakeSearchQueryOption(c, WithSearchQueryConsistencyLevel(entity.CL_SESSION))
+		opt, err = MakeSearchQueryOption(c, WithSearchQueryConsistencyLevel(entity.ClSession))
 		assert.Nil(t, err)
 		assert.NotNil(t, opt)
 		expected = &SearchQueryOption{
-			ConsistencyLevel:   entity.CL_SESSION,
+			ConsistencyLevel:   entity.ClSession,
 			GuaranteeTimestamp: 99,
 		}
 		assert.Equal(t, expected, opt)
 	})
 
 	t.Run("bounded consistency", func(t *testing.T) {
-		opt, err := MakeSearchQueryOption(c, WithSearchQueryConsistencyLevel(entity.CL_BOUNDED))
+		opt, err := MakeSearchQueryOption(c, WithSearchQueryConsistencyLevel(entity.ClBounded))
 		assert.Nil(t, err)
 		assert.NotNil(t, opt)
 		expected := &SearchQueryOption{
-			ConsistencyLevel:   entity.CL_BOUNDED,
+			ConsistencyLevel:   entity.ClBounded,
 			GuaranteeTimestamp: BoundedTimestamp,
 		}
 		assert.Equal(t, expected, opt)
 	})
 
 	t.Run("eventually consistency", func(t *testing.T) {
-		opt, err := MakeSearchQueryOption(c, WithSearchQueryConsistencyLevel(entity.CL_EVENTUALLY))
+		opt, err := MakeSearchQueryOption(c, WithSearchQueryConsistencyLevel(entity.ClEventually))
 		assert.Nil(t, err)
 		assert.NotNil(t, opt)
 		expected := &SearchQueryOption{
-			ConsistencyLevel:   entity.CL_EVENTUALLY,
+			ConsistencyLevel:   entity.ClEventually,
 			GuaranteeTimestamp: EventuallyTimestamp,
 		}
 		assert.Equal(t, expected, opt)
 	})
 
 	t.Run("customized consistency", func(t *testing.T) {
-		opt, err := MakeSearchQueryOption(c, WithSearchQueryConsistencyLevel(entity.CL_CUSTOMIZED), WithGuaranteeTimestamp(100))
+		opt, err := MakeSearchQueryOption(c, WithSearchQueryConsistencyLevel(entity.ClCustomized), WithGuaranteeTimestamp(100))
 		assert.Nil(t, err)
 		assert.NotNil(t, opt)
 		expected := &SearchQueryOption{
-			ConsistencyLevel:   entity.CL_CUSTOMIZED,
+			ConsistencyLevel:   entity.ClCustomized,
 			GuaranteeTimestamp: 100,
 		}
 		assert.Equal(t, expected, opt)
 	})
 
 	t.Run("guarantee timestamp sanity check", func(t *testing.T) {
-		_, err := MakeSearchQueryOption(c, WithSearchQueryConsistencyLevel(entity.CL_STRONG), WithGuaranteeTimestamp(100))
+		_, err := MakeSearchQueryOption(c, WithSearchQueryConsistencyLevel(entity.ClStrong), WithGuaranteeTimestamp(100))
 		assert.Error(t, err)
 	})
 }
diff --git a/client/client_grpc_partition_test.go b/client/client_grpc_partition_test.go
index 08590f4..108c44e 100644
--- a/client/client_grpc_partition_test.go
+++ b/client/client_grpc_partition_test.go
@@ -235,7 +235,7 @@ func TestGrpcClientLoadPartitions(t *testing.T) {
 			assert.Equal(t, testCollectionName, req.GetCollectionName())
 			resp.PartitionIDs = make([]int64, 0, len(tc.loadNames))
 			resp.PartitionNames = make([]string, 0, len(tc.loadNames))
-			var perc int64 = 0
+			var perc int64
 			if time.Since(start) > time.Duration(loadTime*int(time.Millisecond)) {
 				perc = 100
 				loaded = true
@@ -291,7 +291,7 @@ func TestGrpcClientLoadPartitions(t *testing.T) {
 			assert.Equal(t, testCollectionName, req.GetCollectionName())
 			resp.PartitionIDs = make([]int64, 0, len(tc.loadNames))
 			resp.PartitionNames = make([]string, 0, len(tc.loadNames))
-			var perc int64 = 0
+			var perc int64
 			for _, part := range tc.partitions {
 				resp.PartitionIDs = append(resp.PartitionIDs, part.ID)
 				resp.PartitionNames = append(resp.PartitionNames, part.Name)
diff --git a/client/client_mock_test.go b/client/client_mock_test.go
index e4a1fd8..fe22425 100644
--- a/client/client_mock_test.go
+++ b/client/client_mock_test.go
@@ -91,7 +91,7 @@ func defaultSchema() *entity.Schema {
 				Name:     testVectorField,
 				DataType: entity.FieldTypeFloatVector,
 				TypeParams: map[string]string{
-					entity.TYPE_PARAM_DIM: fmt.Sprintf("%d", testVectorDim),
+					entity.TypeParamDim: fmt.Sprintf("%d", testVectorDim),
 				},
 			},
 		},
@@ -109,14 +109,14 @@ func varCharSchema() *entity.Schema {
 				PrimaryKey: true,
 				AutoID:     false,
 				TypeParams: map[string]string{
-					entity.TYPE_PARAM_MAX_LENGTH: fmt.Sprintf("%d", 100),
+					entity.TypeParamMaxLength: fmt.Sprintf("%d", 100),
 				},
 			},
 			{
 				Name:     testVectorField,
 				DataType: entity.FieldTypeFloatVector,
 				TypeParams: map[string]string{
-					entity.TYPE_PARAM_DIM: fmt.Sprintf("%d", testVectorDim),
+					entity.TypeParamDim: fmt.Sprintf("%d", testVectorDim),
 				},
 			},
 		},
diff --git a/client/interceptor_test.go b/client/interceptor_test.go
index e31897e..e9bb982 100644
--- a/client/interceptor_test.go
+++ b/client/interceptor_test.go
@@ -3,10 +3,11 @@ package client
 import (
 	"context"
 	"fmt"
+	"testing"
+
 	"github.com/milvus-io/milvus-sdk-go/v2/internal/utils/crypto"
 	"github.com/stretchr/testify/assert"
 	"google.golang.org/grpc/metadata"
-	"testing"
 )
 
 const (
diff --git a/client/timestamp_map_test.go b/client/timestamp_map_test.go
index d095284..a30891e 100644
--- a/client/timestamp_map_test.go
+++ b/client/timestamp_map_test.go
@@ -1,8 +1,9 @@
 package client
 
 import (
-	"github.com/stretchr/testify/assert"
 	"testing"
+
+	"github.com/stretchr/testify/assert"
 )
 
 func TestTimestampMap(t *testing.T) {
diff --git a/entity/columns_varchar_test.go b/entity/columns_varchar_test.go
index dd67af4..0570ddc 100644
--- a/entity/columns_varchar_test.go
+++ b/entity/columns_varchar_test.go
@@ -2,11 +2,12 @@ package entity
 
 import (
 	"fmt"
-	"github.com/milvus-io/milvus-sdk-go/v2/internal/proto/schema"
-	"github.com/stretchr/testify/assert"
 	"math/rand"
 	"testing"
 	"time"
+
+	"github.com/milvus-io/milvus-sdk-go/v2/internal/proto/schema"
+	"github.com/stretchr/testify/assert"
 )
 
 func TestColumnVarChar(t *testing.T) {
diff --git a/entity/schema_test.go b/entity/schema_test.go
index e60e7b2..e5ec79b 100644
--- a/entity/schema_test.go
+++ b/entity/schema_test.go
@@ -9,10 +9,10 @@ import (
 
 func TestCL_CommonCL(t *testing.T) {
 	cls := []ConsistencyLevel{
-		CL_STRONG,
-		CL_BOUNDED,
-		CL_SESSION,
-		CL_EVENTUALLY,
+		ClStrong,
+		ClBounded,
+		ClSession,
+		ClEventually,
 	}
 	for _, cl := range cls {
 		assert.EqualValues(t, common.ConsistencyLevel(cl), cl.CommonConsistencyLevel())
diff --git a/tests/client_collection_test.go b/tests/client_collection_test.go
index 236d96c..5a9d75c 100644
--- a/tests/client_collection_test.go
+++ b/tests/client_collection_test.go
@@ -55,7 +55,7 @@ func TestCreateCollection(t *testing.T) {
 				Name:     "vector",
 				DataType: entity.FieldTypeFloatVector,
 				TypeParams: map[string]string{
-					entity.TYPE_PARAM_DIM: "128",
+					entity.TypeParamDim: "128",
 				},
 			},
 		},
diff --git a/tests/collection_test.go b/tests/collection_test.go
index 6be6bba..f4b24b3 100644
--- a/tests/collection_test.go
+++ b/tests/collection_test.go
@@ -3,10 +3,11 @@ package tests
 import (
 	"context"
 	"fmt"
+	"testing"
+
 	"github.com/milvus-io/milvus-sdk-go/v2/entity"
 	ut "github.com/milvus-io/milvus-sdk-go/v2/tests/testutil"
 	"github.com/stretchr/testify/assert"
-	"testing"
 )
 
 var nameTests = []struct {
@@ -27,7 +28,7 @@ var dimTests = []struct {
 }
 
 // Test create collection with default schema
-func TestClientCreateCollection(t *testing.T)  {
+func TestClientCreateCollection(t *testing.T) {
 	ctx := context.Background()
 	c := GenClient(t)
 	name := ut.GenRandomString(8)
@@ -41,7 +42,7 @@ func TestClientCreateCollection(t *testing.T)  {
 }
 
 // Test create collection without name, expected an error
-func TestCollectionWithoutName(t *testing.T)  {
+func TestCollectionWithoutName(t *testing.T) {
 	ctx := context.Background()
 	c := GenClient(t)
 	fields := ut.GenDefaultFields(ut.DefaultDim)
@@ -55,7 +56,7 @@ func TestCollectionWithoutName(t *testing.T)  {
 }
 
 // Test create collection without fields, expected an error
-func TestCollectionWithoutFields(t *testing.T)  {
+func TestCollectionWithoutFields(t *testing.T) {
 	ctx := context.Background()
 	c := GenClient(t)
 	//fields := ut.GenDefaultFields()
@@ -69,7 +70,7 @@ func TestCollectionWithoutFields(t *testing.T)  {
 }
 
 // Test create collection with invalid name, expected an error
-func TestCollectionInvalidName(t *testing.T)  {
+func TestCollectionInvalidName(t *testing.T) {
 	ctx := context.Background()
 	c := GenClient(t)
 	fields := ut.GenDefaultFields(ut.DefaultDim)
@@ -86,7 +87,7 @@ func TestCollectionInvalidName(t *testing.T)  {
 
 // TODO issue: #217
 // Test create collection with invalid field name, expected an error
-func TestCollectionInvalidFieldName(t *testing.T)  {
+func TestCollectionInvalidFieldName(t *testing.T) {
 	ctx := context.Background()
 	c := GenClient(t)
 	fields := ut.GenDefaultFields(ut.DefaultDim)
@@ -100,10 +101,9 @@ func TestCollectionInvalidFieldName(t *testing.T)  {
 	}
 }
 
-
 // TODO issue: #218
 // Test create autoId collection
-func TestCollectionAutoId(t *testing.T)  {
+func TestCollectionAutoId(t *testing.T) {
 	t.Skip("issue #218")
 
 	ctx := context.Background()
@@ -114,7 +114,7 @@ func TestCollectionAutoId(t *testing.T)  {
 	schema := ut.GenSchema(name, true, fields)
 	t.Logf("exp autoId: %t", schema.AutoID)
 	c.CreateCollection(ctx, schema, ut.DefaultShards)
-	collection, _ :=c.DescribeCollection(ctx, name)
+	collection, _ := c.DescribeCollection(ctx, name)
 	t.Logf("actual name: %s", collection.Name)
 	t.Logf("actual autoId: %t", collection.Schema.AutoID)
 	assert.Equal(t, schema.AutoID, collection.Schema.AutoID)
@@ -122,22 +122,22 @@ func TestCollectionAutoId(t *testing.T)  {
 
 // TODO issue: #219
 // Test create collection only with vector field, expected an error
-func TestCollectionOnlyVector(t *testing.T)  {
+func TestCollectionOnlyVector(t *testing.T) {
 	ctx := context.Background()
 	c := GenClient(t)
 	name := ut.GenRandomString(8)
-	var fields = []*entity.Field {
+	var fields = []*entity.Field{
 		{
 			Name:     name,
 			DataType: entity.FieldTypeFloatVector,
-			TypeParams: map[string]string {
+			TypeParams: map[string]string{
 				"dim": fmt.Sprintf("%d", ut.DefaultDim),
 			},
 		},
 	}
 	schema := &entity.Schema{
 		CollectionName: name,
-		Fields: fields,
+		Fields:         fields,
 	}
 	err := c.CreateCollection(ctx, schema, ut.DefaultShards)
 	t.Log(err)
@@ -146,20 +146,20 @@ func TestCollectionOnlyVector(t *testing.T)  {
 }
 
 // Test create collection without vector field, expected an error
-func TestCollectionWithoutVector(t *testing.T)  {
+func TestCollectionWithoutVector(t *testing.T) {
 	ctx := context.Background()
 	c := GenClient(t)
-	fields := []*entity.Field {
+	fields := []*entity.Field{
 		{
-			Name: ut.DefaultIntFieldName,
-			DataType: entity.FieldTypeInt64,
+			Name:       ut.DefaultIntFieldName,
+			DataType:   entity.FieldTypeInt64,
 			PrimaryKey: true,
 		},
 	}
 	name := ut.GenRandomString(8)
-	schema := &entity.Schema {
+	schema := &entity.Schema{
 		CollectionName: name,
-		Fields: fields,
+		Fields:         fields,
 	}
 	err := c.CreateCollection(ctx, schema, ut.DefaultShards)
 	expError := "vector field not set"
@@ -168,7 +168,7 @@ func TestCollectionWithoutVector(t *testing.T)  {
 
 // Test create collection with invalid dim
 // TODO issue: #220
-func TestCollectionInvalidDim(t *testing.T)  {
+func TestCollectionInvalidDim(t *testing.T) {
 	ctx := context.Background()
 	c := GenClient(t)
 	for _, test := range dimTests {
@@ -183,25 +183,25 @@ func TestCollectionInvalidDim(t *testing.T)  {
 
 // Test create collection with wrong keyword "dim", like "dims", expected an error
 // TODO issue: #221
-func TestCollectionWrongDimKey(t *testing.T)  {
+func TestCollectionWrongDimKey(t *testing.T) {
 	ctx := context.Background()
 	c := GenClient(t)
 	name := ut.GenRandomString(8)
-	fields := []*entity.Field {
+	fields := []*entity.Field{
 		{
-			Name: ut.DefaultIntFieldName,
-			DataType: entity.FieldTypeInt64,
+			Name:       ut.DefaultIntFieldName,
+			DataType:   entity.FieldTypeInt64,
 			PrimaryKey: true,
 		},
 		{
-			Name: ut.DefaultFloatVecFieldName,
+			Name:     ut.DefaultFloatVecFieldName,
 			DataType: entity.FieldTypeFloatVector,
 			TypeParams: map[string]string{
-				"dims" : fmt.Sprintf("%d", ut.DefaultDim),
+				"dims": fmt.Sprintf("%d", ut.DefaultDim),
 			},
 		},
 	}
 	schema := ut.GenSchema(name, false, fields)
 	err := c.CreateCollection(ctx, schema, ut.DefaultShards)
 	t.Log(err)
-}
\ No newline at end of file
+}
diff --git a/tests/connect_test.go b/tests/connect_test.go
index 76bc6d0..e21149d 100644
--- a/tests/connect_test.go
+++ b/tests/connect_test.go
@@ -3,13 +3,14 @@ package tests
 import (
 	"context"
 	"fmt"
-	"github.com/milvus-io/milvus-sdk-go/v2/client"
-	"github.com/stretchr/testify/assert"
 	"reflect"
 	"testing"
+
+	"github.com/milvus-io/milvus-sdk-go/v2/client"
+	"github.com/stretchr/testify/assert"
 )
 
-func TestClientConnect(t *testing.T)  {
+func TestClientConnect(t *testing.T) {
 	c, err := client.NewGrpcClient(context.Background(), GenMilvusAddr())
 	assert.NoError(t, err)
 	tp := reflect.TypeOf(c)
@@ -18,7 +19,7 @@ func TestClientConnect(t *testing.T)  {
 	defer c.Close()
 }
 
-func TestConnectRepeatedly(t *testing.T)  {
+func TestConnectRepeatedly(t *testing.T) {
 	c, err := client.NewGrpcClient(context.Background(), GenMilvusAddr())
 	assert.NoError(t, err)
 	c1, err1 := client.NewGrpcClient(context.Background(), GenMilvusAddr())
@@ -27,8 +28,8 @@ func TestConnectRepeatedly(t *testing.T)  {
 	defer c.Close()
 }
 
-func TestConnectInvalid(t *testing.T)  {
-	addrTests := []struct{
+func TestConnectInvalid(t *testing.T) {
+	addrTests := []struct {
 		addr string
 	}{
 		{fmt.Sprintf("%s%d", host, port)},
@@ -55,10 +56,10 @@ func TestClose(t *testing.T) {
 	assert.EqualError(t, err1, errString)
 }
 
-func TestCloseRepeatedly(t *testing.T)  {
+func TestCloseRepeatedly(t *testing.T) {
 	c := GenClient(t)
 	res := c.Close()
 	assert.NoError(t, res)
 	res1 := c.Close()
 	assert.NoError(t, res1)
-}
\ No newline at end of file
+}
diff --git a/tests/main_test.go b/tests/main_test.go
index 7ea7c4b..11f7d8f 100644
--- a/tests/main_test.go
+++ b/tests/main_test.go
@@ -4,16 +4,17 @@ import (
 	"context"
 	"flag"
 	"fmt"
-	"github.com/milvus-io/milvus-sdk-go/v2/client"
-	ut "github.com/milvus-io/milvus-sdk-go/v2/tests/testutil"
 	"os"
 	"testing"
+
+	"github.com/milvus-io/milvus-sdk-go/v2/client"
+	ut "github.com/milvus-io/milvus-sdk-go/v2/tests/testutil"
 )
 
 var host string
 var port int64
 
-func init()  {
+func init() {
 	flag.StringVar(&host, "host", "localhost", "server host")
 	flag.Int64Var(&port, "port", 19530, "server port")
 }
@@ -36,7 +37,7 @@ func GenClient(t *testing.T) client.Client {
 }
 
 // Generate an collection
-func GenCollection(t *testing.T, name string)  {
+func GenCollection(t *testing.T, name string) {
 	t.Helper()
 	c := GenClient(t)
 	fields := ut.GenDefaultFields(ut.DefaultDim)
@@ -47,7 +48,7 @@ func GenCollection(t *testing.T, name string)  {
 	}
 }
 
-func teardown()  {
+func teardown() {
 	fmt.Println("Start to tear down")
 	ctx := context.Background()
 	client, _ := client.NewGrpcClient(context.Background(), GenMilvusAddr())
@@ -59,9 +60,9 @@ func teardown()  {
 	defer client.Close()
 }
 
-func TestMain(m *testing.M)  {
+func TestMain(m *testing.M) {
 	flag.Parse()
 	code := m.Run()
 	teardown()
 	os.Exit(code)
-}
\ No newline at end of file
+}
diff --git a/tests/testutil/common.go b/tests/testutil/common.go
index 8c4f4da..c23d0a2 100644
--- a/tests/testutil/common.go
+++ b/tests/testutil/common.go
@@ -13,4 +13,3 @@ const (
 
 	DefaultShards = 4
 )
-
diff --git a/tests/testutil/utils.go b/tests/testutil/utils.go
index ab6bcf6..9c75702 100644
--- a/tests/testutil/utils.go
+++ b/tests/testutil/utils.go
@@ -8,7 +8,7 @@ import (
 	"github.com/milvus-io/milvus-sdk-go/v2/entity"
 )
 
-var r *rand.Rand = nil
+var r *rand.Rand
 
 func init() {
 	r = rand.New(rand.NewSource(time.Now().UnixNano()))
@@ -40,7 +40,7 @@ func GenDefaultFields(dim int64) []*entity.Field {
 			Name:     DefaultFloatVecFieldName,
 			DataType: entity.FieldTypeFloatVector,
 			TypeParams: map[string]string{
-				entity.TYPE_PARAM_DIM: fmt.Sprintf("%d", dim),
+				entity.TypeParamDim: fmt.Sprintf("%d", dim),
 			},
 		},
 	}
diff --git a/tests/util.go b/tests/util.go
index b275705..f5c0d81 100644
--- a/tests/util.go
+++ b/tests/util.go
@@ -72,7 +72,7 @@ func defaultSchema() *entity.Schema {
 				Name:     testVectorField,
 				DataType: entity.FieldTypeFloatVector,
 				TypeParams: map[string]string{
-					entity.TYPE_PARAM_DIM: fmt.Sprintf("%d", testVectorDim),
+					entity.TypeParamDim: fmt.Sprintf("%d", testVectorDim),
 				},
 				IndexParams: map[string]string{
 					"metric_type": "L2",