备份一下
This commit is contained in:
@@ -3,7 +3,6 @@ package config
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
"unsafe"
|
||||
@@ -93,8 +92,9 @@ func (c *Config) Validate() error {
|
||||
if c.Redis.Address == "" {
|
||||
return fmt.Errorf("invalid configuration: redis.address: must be non-empty (current value: empty)")
|
||||
}
|
||||
if !strings.Contains(c.Redis.Address, ":") {
|
||||
return fmt.Errorf("invalid configuration: redis.address: invalid format (current value: %s, expected: HOST:PORT)", c.Redis.Address)
|
||||
// Port 验证(独立字段)
|
||||
if c.Redis.Port <= 0 || c.Redis.Port > 65535 {
|
||||
return fmt.Errorf("invalid configuration: redis.port: port number out of range (current value: %d, expected: 1-65535)", c.Redis.Port)
|
||||
}
|
||||
if c.Redis.DB < 0 || c.Redis.DB > 15 {
|
||||
return fmt.Errorf("invalid configuration: redis.db: database number out of range (current value: %d, expected: 0-15)", c.Redis.DB)
|
||||
|
||||
Reference in New Issue
Block a user