@@ -311,9 +311,11 @@ func (disc *PluggableDiscovery) Run() (err error) {
311
311
if msg , err := disc .waitMessage (time .Second * 10 ); err != nil {
312
312
return fmt .Errorf (tr ("calling %[1]s: %[2]w" ), "HELLO" , err )
313
313
} else if msg .EventType != "hello" {
314
- return errors .Errorf (tr ("communication out of sync, expected 'hello ', received '%s'" ), msg .EventType )
315
- } else if msg .Message != "OK" || msg . Error {
314
+ return errors .Errorf (tr ("communication out of sync, expected '%[1]s ', received '%[2] s'" ), "hello" , msg .EventType )
315
+ } else if msg .Error {
316
316
return errors .Errorf (tr ("command failed: %s" ), msg .Message )
317
+ } else if strings .ToUpper (msg .Message ) != "OK" {
318
+ return errors .Errorf (tr ("communication out of sync, expected '%[1]s', received '%[2]s'" ), "OK" , msg .Message )
317
319
} else if msg .ProtocolVersion > 1 {
318
320
return errors .Errorf (tr ("protocol version not supported: requested 1, got %d" ), msg .ProtocolVersion )
319
321
}
@@ -332,9 +334,11 @@ func (disc *PluggableDiscovery) Start() error {
332
334
if msg , err := disc .waitMessage (time .Second * 10 ); err != nil {
333
335
return fmt .Errorf (tr ("calling %[1]s: %[2]w" ), "START" , err )
334
336
} else if msg .EventType != "start" {
335
- return errors .Errorf (tr ("communication out of sync, expected 'start ', received '%s'" ), msg .EventType )
336
- } else if msg .Message != "OK" || msg . Error {
337
+ return errors .Errorf (tr ("communication out of sync, expected '%[1]s ', received '%[2] s'" ), "start" , msg .EventType )
338
+ } else if msg .Error {
337
339
return errors .Errorf (tr ("command failed: %s" ), msg .Message )
340
+ } else if strings .ToUpper (msg .Message ) != "OK" {
341
+ return errors .Errorf (tr ("communication out of sync, expected '%[1]s', received '%[2]s'" ), "OK" , msg .Message )
338
342
}
339
343
disc .statusMutex .Lock ()
340
344
defer disc .statusMutex .Unlock ()
@@ -352,9 +356,11 @@ func (disc *PluggableDiscovery) Stop() error {
352
356
if msg , err := disc .waitMessage (time .Second * 10 ); err != nil {
353
357
return fmt .Errorf (tr ("calling %[1]s: %[2]w" ), "STOP" , err )
354
358
} else if msg .EventType != "stop" {
355
- return errors .Errorf (tr ("communication out of sync, expected 'stop ', received '%s'" ), msg .EventType )
356
- } else if msg .Message != "OK" || msg . Error {
359
+ return errors .Errorf (tr ("communication out of sync, expected '%[1]s ', received '%[2] s'" ), "stop" , msg .EventType )
360
+ } else if msg .Error {
357
361
return errors .Errorf (tr ("command failed: %s" ), msg .Message )
362
+ } else if strings .ToUpper (msg .Message ) != "OK" {
363
+ return errors .Errorf (tr ("communication out of sync, expected '%[1]s', received '%[2]s'" ), "OK" , msg .Message )
358
364
}
359
365
disc .statusMutex .Lock ()
360
366
defer disc .statusMutex .Unlock ()
@@ -375,9 +381,11 @@ func (disc *PluggableDiscovery) Quit() error {
375
381
if msg , err := disc .waitMessage (time .Second * 10 ); err != nil {
376
382
return fmt .Errorf (tr ("calling %[1]s: %[2]w" ), "QUIT" , err )
377
383
} else if msg .EventType != "quit" {
378
- return errors .Errorf (tr ("communication out of sync, expected 'quit ', received '%s'" ), msg .EventType )
379
- } else if msg .Message != "OK" || msg . Error {
384
+ return errors .Errorf (tr ("communication out of sync, expected '%[1]s ', received '%[2] s'" ), "quit" , msg .EventType )
385
+ } else if msg .Error {
380
386
return errors .Errorf (tr ("command failed: %s" ), msg .Message )
387
+ } else if strings .ToUpper (msg .Message ) != "OK" {
388
+ return errors .Errorf (tr ("communication out of sync, expected '%[1]s', received '%[2]s'" ), "OK" , msg .Message )
381
389
}
382
390
disc .killProcess ()
383
391
return nil
@@ -392,7 +400,7 @@ func (disc *PluggableDiscovery) List() ([]*Port, error) {
392
400
if msg , err := disc .waitMessage (time .Second * 10 ); err != nil {
393
401
return nil , fmt .Errorf (tr ("calling %[1]s: %[2]w" ), "LIST" , err )
394
402
} else if msg .EventType != "list" {
395
- return nil , errors .Errorf (tr ("communication out of sync, expected 'list ', received '%s'" ), msg .EventType )
403
+ return nil , errors .Errorf (tr ("communication out of sync, expected '%[1]s ', received '%[2] s'" ), "list" , msg .EventType )
396
404
} else if msg .Error {
397
405
return nil , errors .Errorf (tr ("command failed: %s" ), msg .Message )
398
406
} else {
@@ -415,9 +423,11 @@ func (disc *PluggableDiscovery) StartSync(size int) (<-chan *Event, error) {
415
423
if msg , err := disc .waitMessage (time .Second * 10 ); err != nil {
416
424
return nil , fmt .Errorf (tr ("calling %[1]s: %[2]w" ), "START_SYNC" , err )
417
425
} else if msg .EventType != "start_sync" {
418
- return nil , errors .Errorf (tr ("communication out of sync, expected 'start_sync ', received '%s'" ), msg .EventType )
419
- } else if msg .Message != "OK" || msg . Error {
426
+ return nil , errors .Errorf (tr ("communication out of sync, expected '%[1]s ', received '%[2] s'" ), "start_sync" , msg .EventType )
427
+ } else if msg .Error {
420
428
return nil , errors .Errorf (tr ("command failed: %s" ), msg .Message )
429
+ } else if strings .ToUpper (msg .Message ) != "OK" {
430
+ return nil , errors .Errorf (tr ("communication out of sync, expected '%[1]s', received '%[2]s'" ), "OK" , msg .Message )
421
431
}
422
432
423
433
disc .statusMutex .Lock ()
0 commit comments