@@ -71,16 +71,16 @@ type discoveryMessage struct {
71
71
func (msg discoveryMessage ) String () string {
72
72
s := fmt .Sprintf ("type: %s" , msg .EventType )
73
73
if msg .Message != "" {
74
- s = fmt .Sprintf ("% s, message: %s" , s , msg .Message )
74
+ s = fmt .Sprintf (tr ( "%[1] s, message: %[2]s" ) , s , msg .Message )
75
75
}
76
76
if msg .ProtocolVersion != 0 {
77
- s = fmt .Sprintf ("% s, protocol version: %d" , s , msg .ProtocolVersion )
77
+ s = fmt .Sprintf (tr ( "%[1] s, protocol version: %[2]d" ) , s , msg .ProtocolVersion )
78
78
}
79
79
if len (msg .Ports ) > 0 {
80
- s = fmt .Sprintf ("% s, ports: %s" , s , msg .Ports )
80
+ s = fmt .Sprintf (tr ( "%[1] s, ports: %[2]s" ) , s , msg .Ports )
81
81
}
82
82
if msg .Port != nil {
83
- s = fmt .Sprintf ("% s, port: %s" , s , msg .Port )
83
+ s = fmt .Sprintf (tr ( "%[1] s, port: %[2]s" ) , s , msg .Port )
84
84
}
85
85
return s
86
86
}
@@ -225,7 +225,7 @@ func (disc *PluggableDiscovery) waitMessage(timeout time.Duration) (*discoveryMe
225
225
}
226
226
return msg , nil
227
227
case <- time .After (timeout ):
228
- return nil , fmt .Errorf ("timeout waiting for message from %s" , disc .id )
228
+ return nil , fmt .Errorf (tr ( "timeout waiting for message from %s" ) , disc .id )
229
229
}
230
230
}
231
231
@@ -294,7 +294,7 @@ func (disc *PluggableDiscovery) Run() (err error) {
294
294
return err
295
295
}
296
296
if msg , err := disc .waitMessage (time .Second * 10 ); err != nil {
297
- return fmt .Errorf ("calling HELLO : %w " , err )
297
+ return fmt .Errorf (tr ( "calling %[1]s : %[2]w" ), "HELLO " , err )
298
298
} else if msg .EventType != "hello" {
299
299
return errors .Errorf (tr ("communication out of sync, expected 'hello', received '%s'" ), msg .EventType )
300
300
} else if msg .Message != "OK" || msg .Error {
@@ -315,7 +315,7 @@ func (disc *PluggableDiscovery) Start() error {
315
315
return err
316
316
}
317
317
if msg , err := disc .waitMessage (time .Second * 10 ); err != nil {
318
- return fmt .Errorf ("calling START : %w " , err )
318
+ return fmt .Errorf (tr ( "calling %[1]s : %[2]w" ), "START " , err )
319
319
} else if msg .EventType != "start" {
320
320
return errors .Errorf (tr ("communication out of sync, expected 'start', received '%s'" ), msg .EventType )
321
321
} else if msg .Message != "OK" || msg .Error {
@@ -335,7 +335,7 @@ func (disc *PluggableDiscovery) Stop() error {
335
335
return err
336
336
}
337
337
if msg , err := disc .waitMessage (time .Second * 10 ); err != nil {
338
- return fmt .Errorf ("calling STOP : %w " , err )
338
+ return fmt .Errorf (tr ( "calling %[1]s : %[2]w" ), "STOP " , err )
339
339
} else if msg .EventType != "stop" {
340
340
return errors .Errorf (tr ("communication out of sync, expected 'stop', received '%s'" ), msg .EventType )
341
341
} else if msg .Message != "OK" || msg .Error {
@@ -358,7 +358,7 @@ func (disc *PluggableDiscovery) Quit() error {
358
358
return err
359
359
}
360
360
if msg , err := disc .waitMessage (time .Second * 10 ); err != nil {
361
- return fmt .Errorf ("calling QUIT : %w " , err )
361
+ return fmt .Errorf (tr ( "calling %[1]s : %[2]w" ), "QUIT " , err )
362
362
} else if msg .EventType != "quit" {
363
363
return errors .Errorf (tr ("communication out of sync, expected 'quit', received '%s'" ), msg .EventType )
364
364
} else if msg .Message != "OK" || msg .Error {
@@ -381,7 +381,7 @@ func (disc *PluggableDiscovery) List() ([]*Port, error) {
381
381
return nil , err
382
382
}
383
383
if msg , err := disc .waitMessage (time .Second * 10 ); err != nil {
384
- return nil , fmt .Errorf ("calling LIST : %w " , err )
384
+ return nil , fmt .Errorf (tr ( "calling %[1]s : %[2]w" ), "LIST " , err )
385
385
} else if msg .EventType != "list" {
386
386
return nil , errors .Errorf (tr ("communication out of sync, expected 'list', received '%s'" ), msg .EventType )
387
387
} else if msg .Error {
@@ -404,7 +404,7 @@ func (disc *PluggableDiscovery) StartSync(size int) (<-chan *Event, error) {
404
404
}
405
405
406
406
if msg , err := disc .waitMessage (time .Second * 10 ); err != nil {
407
- return nil , fmt .Errorf ("calling START_SYNC : %w " , err )
407
+ return nil , fmt .Errorf (tr ( "calling %[1]s : %[2]w" ), "START_SYNC " , err )
408
408
} else if msg .EventType != "start_sync" {
409
409
return nil , errors .Errorf (tr ("communication out of sync, expected 'start_sync', received '%s'" ), msg .EventType )
410
410
} else if msg .Message != "OK" || msg .Error {
0 commit comments