diff --git a/internal/info/info.go b/internal/info/info.go index 246b284aa6..8d2fa6cfdd 100644 --- a/internal/info/info.go +++ b/internal/info/info.go @@ -1,4 +1,5 @@ // +// // Copyright (C) 2019-2022 vdaas.org vald team // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -262,11 +263,11 @@ func (d Detail) String() string { // Get returns parased Detail object. func (i *info) Get() Detail { i.prepare() - return i.get() + return i.getDetail() } // skipcq: VET-V0008 -func (i info) get() Detail { +func (i info) getDetail() Detail { i.detail.StackTrace = make([]StackTrace, 0, 10) for j := 2; ; j++ { pc, file, line, ok := i.rtCaller(j) diff --git a/internal/info/info_test.go b/internal/info/info_test.go index 3ddb25f78c..24611be798 100644 --- a/internal/info/info_test.go +++ b/internal/info/info_test.go @@ -1567,7 +1567,7 @@ func TestStackTrace_String(t *testing.T) { } } -func Test_info_get(t *testing.T) { +func Test_info_getDetail(t *testing.T) { type fields struct { baseURL string detail Detail @@ -1649,7 +1649,7 @@ func Test_info_get(t *testing.T) { rtFuncForPC: test.fields.rtFuncForPC, } - got := i.get() + got := i.getDetail() if err := checkFunc(test.want, got); err != nil { tt.Errorf("error = %v", err) } diff --git a/internal/net/grpc/pool/pool.go b/internal/net/grpc/pool/pool.go index eaa15a5d02..679a0ac588 100644 --- a/internal/net/grpc/pool/pool.go +++ b/internal/net/grpc/pool/pool.go @@ -357,10 +357,10 @@ func (p *pool) Do(f func(conn *ClientConn) error) error { } func (p *pool) Get() (*ClientConn, bool) { - return p.get(p.Len()) + return p.doGet(p.Len()) } -func (p *pool) get(retry uint64) (*ClientConn, bool) { +func (p *pool) doGet(retry uint64) (*ClientConn, bool) { if retry <= 0 || retry > math.MaxUint64-p.Len() || p.Len() <= 0 { log.Warnf("failed to find grpc pool connection for %s", p.addr) if p.isIP { @@ -378,7 +378,7 @@ func (p *pool) get(retry uint64) (*ClientConn, bool) { } } retry-- - return p.get(retry) + return p.doGet(retry) } func (p *pool) Len() uint64 { diff --git a/internal/net/grpc/pool/pool_test.go b/internal/net/grpc/pool/pool_test.go index 97287c1dbc..fa91ab7408 100644 --- a/internal/net/grpc/pool/pool_test.go +++ b/internal/net/grpc/pool/pool_test.go @@ -1284,7 +1284,7 @@ func Test_pool_Get(t *testing.T) { } } -func Test_pool_get(t *testing.T) { +func Test_pool_doGet(t *testing.T) { t.Parallel() type args struct { retry uint64 @@ -1426,7 +1426,7 @@ func Test_pool_get(t *testing.T) { reconnectHash: test.fields.reconnectHash, } - got, got1 := p.get(test.args.retry) + got, got1 := p.doGet(test.args.retry) if err := checkFunc(test.want, got, got1); err != nil { tt.Errorf("error = %v", err) } diff --git a/internal/test/data/vector/gen.go b/internal/test/data/vector/gen.go index 63dde69a31..1aaa7f89e1 100644 --- a/internal/test/data/vector/gen.go +++ b/internal/test/data/vector/gen.go @@ -63,8 +63,8 @@ func Uint8VectorGenerator(d Distribution) (Uint8VectorGeneratorFunc, error) { } } -// genFloat32Vec return n float32 vectors with dim dimension. -func genFloat32Vec(n, dim int, gen func() float32) (ret [][]float32) { +// doGenFloat32Vec return n float32 vectors with dim dimension. +func doGenFloat32Vec(n, dim int, gen func() float32) (ret [][]float32) { ret = make([][]float32, 0, n) for i := 0; i < n; i++ { @@ -79,18 +79,18 @@ func genFloat32Vec(n, dim int, gen func() float32) (ret [][]float32) { // UniformDistributedFloat32VectorGenerator returns n float32 vectors with dim dimension and their values under Uniform distribution func UniformDistributedFloat32VectorGenerator(n, dim int) [][]float32 { - return genFloat32Vec(n, dim, rand.Float32) + return doGenFloat32Vec(n, dim, rand.Float32) } // GaussianDistributedFloat32VectorGenerator returns n float32 vectors with dim dimension and their values under Gaussian distribution func GaussianDistributedFloat32VectorGenerator(n, dim int) [][]float32 { - return genFloat32Vec(n, dim, func() float32 { + return doGenFloat32Vec(n, dim, func() float32 { return float32(rand.NormFloat64()) }) } -// genUint8Vec return n uint8 vectors with dim dimension -func genUint8Vec(n, dim int, gen func() uint8) (ret [][]uint8) { +// doGenUint8Vec return n uint8 vectors with dim dimension +func doGenUint8Vec(n, dim int, gen func() uint8) (ret [][]uint8) { ret = make([][]uint8, 0, n) for i := 0; i < n; i++ { @@ -105,7 +105,7 @@ func genUint8Vec(n, dim int, gen func() uint8) (ret [][]uint8) { // UniformDistributedUint8VectorGenerator returns n uint8 vectors with dim dimension and their values under Uniform distribution func UniformDistributedUint8VectorGenerator(n, dim int) [][]uint8 { - return genUint8Vec(n, dim, func() uint8 { + return doGenUint8Vec(n, dim, func() uint8 { return uint8(irand.LimitedUint32(math.MaxUint8)) }) } @@ -113,7 +113,7 @@ func UniformDistributedUint8VectorGenerator(n, dim int) [][]uint8 { // GaussianDistributedUint8VectorGenerator returns n uint8 vectors with dim dimension and their values under Gaussian distribution func GaussianDistributedUint8VectorGenerator(n, dim int) [][]uint8 { // NOTE: The boundary test is the main purpose for refactoring. Now, passing this function is dependent on the seed of the random generator. We should fix the randomness of the passing test. - return genUint8Vec(n, dim, func() uint8 { + return doGenUint8Vec(n, dim, func() uint8 { val := rand.NormFloat64()*gaussianSigma + gaussianMean if val < 0 { return 0 diff --git a/internal/test/data/vector/gen_test.go b/internal/test/data/vector/gen_test.go index ce072b80b0..9f7a372bdc 100644 --- a/internal/test/data/vector/gen_test.go +++ b/internal/test/data/vector/gen_test.go @@ -208,7 +208,7 @@ func TestUint8VectorGenerator(t *testing.T) { } } -func Test_genFloat32Vec(t *testing.T) { +func Test_doGenFloat32Vec(t *testing.T) { type args struct { n int dim int @@ -279,7 +279,7 @@ func Test_genFloat32Vec(t *testing.T) { checkFunc = defaultCheckFunc } - gotRet := genFloat32Vec(test.args.n, test.args.dim, test.args.gen) + gotRet := doGenFloat32Vec(test.args.n, test.args.dim, test.args.gen) if err := checkFunc(test.want, gotRet); err != nil { tt.Errorf("error = %v", err) } @@ -439,7 +439,7 @@ func TestGaussianDistributedFloat32VectorGenerator(t *testing.T) { } } -func Test_genUint8Vec(t *testing.T) { +func Test_doGenUint8Vec(t *testing.T) { type args struct { n int dim int @@ -510,7 +510,7 @@ func Test_genUint8Vec(t *testing.T) { checkFunc = defaultCheckFunc } - gotRet := genUint8Vec(test.args.n, test.args.dim, test.args.gen) + gotRet := doGenUint8Vec(test.args.n, test.args.dim, test.args.gen) if err := checkFunc(test.want, gotRet); err != nil { tt.Errorf("error = %v", err) }