Add vet check and fix some vet errors (#374)

This commit is contained in:
Lunny Xiao 2020-04-24 13:07:38 +08:00 committed by GitHub
parent 04ab07acd4
commit 3c399e1b38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 6 deletions

View File

@ -4,4 +4,5 @@ go:
- 1.12.x - 1.12.x
script: script:
- make vet
- make test - make test

View File

@ -22,6 +22,9 @@ build:
go build -mod=vendor -o bin/ledis-load -tags '$(GO_BUILD_TAGS)' cmd/ledis-load/* go build -mod=vendor -o bin/ledis-load -tags '$(GO_BUILD_TAGS)' cmd/ledis-load/*
go build -mod=vendor -o bin/ledis-repair -tags '$(GO_BUILD_TAGS)' cmd/ledis-repair/* go build -mod=vendor -o bin/ledis-repair -tags '$(GO_BUILD_TAGS)' cmd/ledis-repair/*
vet:
go vet -mod=vendor -tags '$(GO_BUILD_TAGS)' ./...
test: test:
go test -mod=vendor --race -tags '$(GO_BUILD_TAGS)' -timeout 2m $$(go list ./... | grep -v -e /vendor/) go test -mod=vendor --race -tags '$(GO_BUILD_TAGS)' -timeout 2m $$(go list ./... | grep -v -e /vendor/)

View File

@ -258,12 +258,10 @@ func main() {
if *number <= 0 { if *number <= 0 {
panic("invalid number") panic("invalid number")
return
} }
if *clients <= 0 || *number < *clients { if *clients <= 0 || *number < *clients {
panic("invalid client number") panic("invalid client number")
return
} }
loop = *number / *clients loop = *number / *clients

View File

@ -100,7 +100,7 @@ type TLS struct {
type AuthMethod func(c *Config, password string) bool type AuthMethod func(c *Config, password string) bool
type Config struct { type Config struct {
m sync.RWMutex `toml:"-"` m *sync.RWMutex `toml:"-"`
AuthPassword string `toml:"auth_password"` AuthPassword string `toml:"auth_password"`
@ -179,6 +179,7 @@ func NewConfigWithData(data []byte) (*Config, error) {
func NewConfigDefault() *Config { func NewConfigDefault() *Config {
cfg := new(Config) cfg := new(Config)
cfg.m = new(sync.RWMutex)
cfg.Addr = DefaultAddr cfg.Addr = DefaultAddr
cfg.HttpAddr = "" cfg.HttpAddr = ""

View File

@ -241,8 +241,6 @@ func (m *master) runReplication(restart bool) {
} }
} }
} }
return
} }
func (m *master) replConf() error { func (m *master) replConf() error {

View File

@ -195,7 +195,10 @@ func (db *DB) NewSnapshot() (driver.ISnapshot, error) {
} }
func (db *DB) Compact() error { func (db *DB) Compact() error {
return db.db.CompactRange(util.Range{nil, nil}) return db.db.CompactRange(util.Range{
Start: nil,
Limit: nil,
})
} }
func init() { func init() {