Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
127c57dc3a | |||
d6b0b8ea36 | |||
23d7841ccf |
@ -23,7 +23,7 @@ type option struct {
|
||||
|
||||
func WithName(name string) Option {
|
||||
return func(o *option) {
|
||||
if name == "" {
|
||||
if name != "" {
|
||||
o.name = name
|
||||
}
|
||||
}
|
||||
@ -31,7 +31,7 @@ func WithName(name string) Option {
|
||||
|
||||
func WithVersion(version string) Option {
|
||||
return func(o *option) {
|
||||
if version == "" {
|
||||
if version != "" {
|
||||
o.version = version
|
||||
}
|
||||
}
|
||||
@ -39,7 +39,7 @@ func WithVersion(version string) Option {
|
||||
|
||||
func WithAddress(address string) Option {
|
||||
return func(o *option) {
|
||||
if address == "" {
|
||||
if address != "" {
|
||||
o.address = address
|
||||
}
|
||||
}
|
||||
|
2
database/cache/new.go
vendored
2
database/cache/new.go
vendored
@ -45,7 +45,7 @@ func New(opts ...OptionFn) (Cache, error) {
|
||||
Password: password,
|
||||
})
|
||||
|
||||
if err = client.Ping(tool.CtxTimeout(cfg.ctx, 5)).Err(); err != nil {
|
||||
if err = client.Ping(tool.TimeoutCtx(cfg.ctx, 5)).Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
19
resp/msg.go
19
resp/msg.go
@ -1,15 +1,16 @@
|
||||
package resp
|
||||
|
||||
const (
|
||||
Msg200 = "操作成功"
|
||||
Msg400 = "参数错误"
|
||||
Msg401 = "该账号登录已失效, 请重新登录"
|
||||
Msg401NoMulti = "用户已在其他地方登录"
|
||||
Msg403 = "权限不足"
|
||||
Msg404 = "资源不存在"
|
||||
Msg500 = "服务器开小差了"
|
||||
Msg501 = "服务不可用"
|
||||
Msg503 = "服务不可用或正在升级, 请联系管理员"
|
||||
Msg200 = "操作成功"
|
||||
Msg400 = "参数错误"
|
||||
Msg401 = "该账号登录已失效, 请重新登录"
|
||||
Msg401NoMulti = "用户已在其他地方登录"
|
||||
Msg401Inactive = "当前用户尚未生效, 请稍后再试"
|
||||
Msg403 = "权限不足"
|
||||
Msg404 = "资源不存在"
|
||||
Msg500 = "服务器开小差了"
|
||||
Msg501 = "服务不可用"
|
||||
Msg503 = "服务不可用或正在升级, 请联系管理员"
|
||||
)
|
||||
|
||||
func Msg(status int) string {
|
||||
|
@ -23,7 +23,7 @@ func Timeout(seconds ...int) (ctx context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
func CtxTimeout(ctx context.Context, seconds ...int) context.Context {
|
||||
func TimeoutCtx(ctx context.Context, seconds ...int) context.Context {
|
||||
var (
|
||||
duration time.Duration
|
||||
)
|
||||
|
Reference in New Issue
Block a user