Add string method
This commit is contained in:
parent
540831e6a9
commit
4c9ef35a9a
|
|
@ -111,6 +111,23 @@ func newConfig(cachePolicy int, ipVersion *xdb.Version, xdbPath string, searcher
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Config) String() string {
|
||||||
|
vIndex := "null"
|
||||||
|
if c.vIndex != nil {
|
||||||
|
vIndex = fmt.Sprintf("{bytes:%d}", len(c.vIndex))
|
||||||
|
}
|
||||||
|
|
||||||
|
cBuffer := "null"
|
||||||
|
if c.cBuffer != nil {
|
||||||
|
cBuffer = fmt.Sprintf("{bytes:%d}", len(c.cBuffer))
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf(
|
||||||
|
"{cache_policy:%d, version:%s, xdb_path:%s, header:%s, v_index:%s, c_buffer:%s}",
|
||||||
|
c.cachePolicy, c.ipVersion.String(), c.xdbPath, c.header.String(), vIndex, cBuffer,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Config) CachePolicy() int {
|
func (c *Config) CachePolicy() int {
|
||||||
return c.cachePolicy
|
return c.cachePolicy
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
// Copyright 2022 The Ip2Region Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a Apache2.0-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package service
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestV4Config(t *testing.T) {
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue