From 30b6fa4c46e4941e3100df9257708c67a07ebe0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 23 Jun 2022 15:36:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E4=BB=BB=E5=8A=A1=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=87=8D=E5=A4=8D=E6=B3=A8=E5=86=8C=E7=9A=84=E6=A3=80?= =?UTF-8?q?=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- task.go | 4 ++++ 1 file changed, 4 insertions(+) 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