diff --git a/task.go b/task.go index 1bca670..f0bdaaf 100644 --- a/task.go +++ b/task.go @@ -9,6 +9,7 @@ package task import ( "context" + "fmt" "sync" ) @@ -48,6 +49,9 @@ func (d *dispatch) Register(taskInstanceList ...ITask) error { if nil == taskInstance { continue } + if _, exist := d.taskTable[taskInstance.Name()]; exist { + return fmt.Errorf("%s 任务重复注册! ", taskInstance.Name()) + } d.taskTable[taskInstance.Name()] = taskInstance } return nil