File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,10 +79,7 @@ func newWorker(o workerOpt) (*worker, error) {
7979 // Check if a worker with the same fileName and moduleID already exists
8080 if existingWorkers , ok := workers [absFileName ]; ok {
8181 for _ , existingWorker := range existingWorkers {
82- if existingWorker .moduleID == o .moduleID {
83- if o .moduleID == 0 {
84- return nil , fmt .Errorf ("cannot add a multiple global workers with the same filename: %s" , absFileName )
85- }
82+ if existingWorker .moduleID == o .moduleID && o .moduleID != 0 {
8683 return existingWorker , nil
8784 }
8885 }
@@ -105,6 +102,14 @@ func newWorker(o workerOpt) (*worker, error) {
105102 // Check if we already have workers for this filename
106103 if _ , ok := workers [absFileName ]; ! ok {
107104 workers [absFileName ] = make ([]* worker , 0 )
105+ } else {
106+ // check if a global worker already exists and overwrite it instead of appending
107+ for i , existingWorker := range workers [absFileName ] {
108+ if existingWorker .moduleID == 0 && o .moduleID == 0 {
109+ workers [absFileName ][i ] = w
110+ return w , nil
111+ }
112+ }
108113 }
109114 workers [absFileName ] = append (workers [absFileName ], w )
110115
You can’t perform that action at this time.
0 commit comments