From d3168bb9f4138a11c084e7fab00831db5626cbfc Mon Sep 17 00:00:00 2001 From: damonchen Date: Fri, 10 Feb 2017 21:13:00 +0800 Subject: [PATCH] change new config parameter to pointer type --- worker.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/worker.go b/worker.go index 6238a28..0c0f9f0 100644 --- a/worker.go +++ b/worker.go @@ -32,12 +32,16 @@ const ( ) // New create Worker with Config -func New(config ...Config) *Worker { - var cfg Config +func New(config ...*Config) *Worker { + var cfg *Config if len(config) > 0 { cfg = config[0] } + if cfg == nil { + cfg = &Config{} + } + if cfg.Job == nil { cfg.Job = &QorJob{} } @@ -46,7 +50,7 @@ func New(config ...Config) *Worker { cfg.Queue = NewCronQueue() } - return &Worker{Config: &cfg} + return &Worker{Config: cfg} } // Config worker config