Skip to content

Commit 113fec8

Browse files
peczenyjZerpet
authored andcommittedJun 6, 2024
run gofumpt -w .
1 parent 450fa53 commit 113fec8

15 files changed

+38
-169
lines changed
 

‎_examples/client/client.go

-6
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ func (client *Client) handleReconnect(addr string) {
180180
client.infolog.Println("attempting to connect")
181181

182182
conn, err := client.connect(addr)
183-
184183
if err != nil {
185184
client.errlog.Println("failed to connect. Retrying...")
186185

@@ -201,7 +200,6 @@ func (client *Client) handleReconnect(addr string) {
201200
// connect will create a new AMQP connection
202201
func (client *Client) connect(addr string) (*amqp.Connection, error) {
203202
conn, err := amqp.Dial(addr)
204-
205203
if err != nil {
206204
return nil, err
207205
}
@@ -220,7 +218,6 @@ func (client *Client) handleReInit(conn *amqp.Connection) bool {
220218
client.m.Unlock()
221219

222220
err := client.init(conn)
223-
224221
if err != nil {
225222
client.errlog.Println("failed to initialize channel, retrying...")
226223

@@ -250,13 +247,11 @@ func (client *Client) handleReInit(conn *amqp.Connection) bool {
250247
// init will initialize channel & declare queue
251248
func (client *Client) init(conn *amqp.Connection) error {
252249
ch, err := conn.Channel()
253-
254250
if err != nil {
255251
return err
256252
}
257253

258254
err = ch.Confirm(false)
259-
260255
if err != nil {
261256
return err
262257
}
@@ -268,7 +263,6 @@ func (client *Client) init(conn *amqp.Connection) error {
268263
false, // No-wait
269264
nil, // Arguments
270265
)
271-
272266
if err != nil {
273267
return err
274268
}

‎allocator_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ func TestAllocatorShouldNotReuseEarly(t *testing.T) {
9595
if want, got := first, third; want != got {
9696
t.Fatalf("expected third allocation to be %d, got: %d", want, got)
9797
}
98-
9998
}
10099

101100
func TestAllocatorReleasesKeepUpWithAllocationsForAllSizes(t *testing.T) {

‎auth.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ func (auth *AMQPlainAuth) Response() string {
5555
}
5656

5757
// ExternalAuth for RabbitMQ-auth-mechanism-ssl.
58-
type ExternalAuth struct {
59-
}
58+
type ExternalAuth struct{}
6059

6160
// Mechanism returns "EXTERNAL"
6261
func (*ExternalAuth) Mechanism() string {
@@ -70,7 +69,6 @@ func (*ExternalAuth) Response() string {
7069

7170
// Finds the first mechanism preferred by the client that the server supports.
7271
func pickSASLMechanism(client []Authentication, serverMechanisms []string) (auth Authentication, ok bool) {
73-
7472
for _, auth = range client {
7573
for _, mech := range serverMechanisms {
7674
if auth.Mechanism() == mech {

‎client_test.go

+6-15
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ type server struct {
2626
tune connectionTuneOk
2727
}
2828

29-
var defaultLogin = "guest"
30-
var defaultPassword = "guest"
31-
var defaultPlainAuth = &PlainAuth{defaultLogin, defaultPassword}
32-
var defaultAMQPlainAuth = &AMQPlainAuth{defaultLogin, defaultPassword}
29+
var (
30+
defaultLogin = "guest"
31+
defaultPassword = "guest"
32+
defaultPlainAuth = &PlainAuth{defaultLogin, defaultPassword}
33+
defaultAMQPlainAuth = &AMQPlainAuth{defaultLogin, defaultPassword}
34+
)
3335

3436
func defaultConfigWithAuth(auth Authentication) Config {
3537
return Config{
@@ -228,7 +230,6 @@ func TestDefaultClientProperties(t *testing.T) {
228230

229231
go func() {
230232
srv.connectionOpen()
231-
232233
}()
233234

234235
if c, err := Open(rwc, defaultConfig()); err != nil {
@@ -246,7 +247,6 @@ func TestDefaultClientProperties(t *testing.T) {
246247
if want, got := defaultLocale, srv.start.Locale; want != got {
247248
t.Errorf("expected locale %s got: %s", want, got)
248249
}
249-
250250
}
251251

252252
func TestCustomClientProperties(t *testing.T) {
@@ -261,7 +261,6 @@ func TestCustomClientProperties(t *testing.T) {
261261

262262
go func() {
263263
srv.connectionOpen()
264-
265264
}()
266265

267266
if c, err := Open(rwc, config); err != nil {
@@ -275,15 +274,13 @@ func TestCustomClientProperties(t *testing.T) {
275274
if want, got := config.Properties["version"], srv.start.ClientProperties["version"]; want != got {
276275
t.Errorf("expected version %s got: %s", want, got)
277276
}
278-
279277
}
280278

281279
func TestOpen(t *testing.T) {
282280
rwc, srv := newSession(t)
283281
t.Cleanup(func() { rwc.Close() })
284282
go func() {
285283
srv.connectionOpen()
286-
287284
}()
288285

289286
if c, err := Open(rwc, defaultConfig()); err != nil {
@@ -333,7 +330,6 @@ func TestChannelOpen(t *testing.T) {
333330
go func() {
334331
srv.connectionOpen()
335332
srv.channelOpen(1)
336-
337333
}()
338334

339335
c, err := Open(rwc, defaultConfig())
@@ -345,7 +341,6 @@ func TestChannelOpen(t *testing.T) {
345341
if err != nil {
346342
t.Fatalf("could not open channel: %v (%s)", ch, err)
347343
}
348-
349344
}
350345

351346
func TestOpenFailedSASLUnsupportedMechanisms(t *testing.T) {
@@ -361,7 +356,6 @@ func TestOpenFailedSASLUnsupportedMechanisms(t *testing.T) {
361356
if err != ErrSASL {
362357
t.Fatalf("expected ErrSASL got: %+v on %+v", err, c)
363358
}
364-
365359
}
366360

367361
func TestOpenAMQPlainAuth(t *testing.T) {
@@ -393,7 +387,6 @@ func TestOpenAMQPlainAuth(t *testing.T) {
393387
if table["PASSWORD"] != defaultPassword {
394388
t.Fatalf("unexpected password: want: %s, got: %s", defaultPassword, table["PASSWORD"])
395389
}
396-
397390
}
398391

399392
func TestOpenFailedCredentials(t *testing.T) {
@@ -410,7 +403,6 @@ func TestOpenFailedCredentials(t *testing.T) {
410403
if err != ErrCredentials {
411404
t.Fatalf("expected ErrCredentials got: %+v on %+v", err, c)
412405
}
413-
414406
}
415407

416408
func TestOpenFailedVhost(t *testing.T) {
@@ -527,7 +519,6 @@ func TestConfirmMultipleOrdersDeliveryTags(t *testing.T) {
527519
t.Fatalf("failed ack, expected ack#%d to be %d, got %d", i, tag, ack.DeliveryTag)
528520
}
529521
}
530-
531522
}
532523

533524
func TestDeferredConfirmations(t *testing.T) {

‎connection.go

-1
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,6 @@ func (c *Connection) reader(r io.Reader) {
754754

755755
for {
756756
frame, err := frames.ReadFrame()
757-
758757
if err != nil {
759758
c.shutdown(&Error{Code: FrameError, Reason: err.Error()})
760759
return

‎consumers.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (subs *consumers) buffer(in chan *Delivery, out chan Delivery) {
5555
defer close(out)
5656
defer subs.Done()
5757

58-
var inflight = in
58+
inflight := in
5959
var queue []*Delivery
6060

6161
for delivery := range in {

‎example_client_test.go

-6
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ func (client *Client) handleReconnect(addr string) {
174174
client.logger.Println("Attempting to connect")
175175

176176
conn, err := client.connect(addr)
177-
178177
if err != nil {
179178
client.logger.Println("Failed to connect. Retrying...")
180179

@@ -195,7 +194,6 @@ func (client *Client) handleReconnect(addr string) {
195194
// connect will create a new AMQP connection
196195
func (client *Client) connect(addr string) (*amqp.Connection, error) {
197196
conn, err := amqp.Dial(addr)
198-
199197
if err != nil {
200198
return nil, err
201199
}
@@ -214,7 +212,6 @@ func (client *Client) handleReInit(conn *amqp.Connection) bool {
214212
client.m.Unlock()
215213

216214
err := client.init(conn)
217-
218215
if err != nil {
219216
client.logger.Println("Failed to initialize channel. Retrying...")
220217

@@ -244,13 +241,11 @@ func (client *Client) handleReInit(conn *amqp.Connection) bool {
244241
// init will initialize channel & declare queue
245242
func (client *Client) init(conn *amqp.Connection) error {
246243
ch, err := conn.Channel()
247-
248244
if err != nil {
249245
return err
250246
}
251247

252248
err = ch.Confirm(false)
253-
254249
if err != nil {
255250
return err
256251
}
@@ -262,7 +257,6 @@ func (client *Client) init(conn *amqp.Connection) error {
262257
false, // No-wait
263258
nil, // Arguments
264259
)
265-
266260
if err != nil {
267261
return err
268262
}

‎examples_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ func ExampleChannel_Confirm_bridge() {
202202
// And the body
203203
Body: msg.Body,
204204
})
205-
206205
if err != nil {
207206
if e := msg.Nack(false, false); e != nil {
208207
log.Printf("nack error: %+v", e)

‎integration_test.go

+2-7
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,8 @@ func (c Publishing) Generate(r *rand.Rand, _ int) reflect.Value {
884884
var t reflect.Value
885885

886886
p := Publishing{}
887-
//p.DeliveryMode = uint8(r.Intn(3))
888-
//p.Priority = uint8(r.Intn(8))
887+
// p.DeliveryMode = uint8(r.Intn(3))
888+
// p.Priority = uint8(r.Intn(8))
889889

890890
if r.Intn(2) > 0 {
891891
p.ContentType = "application/octet-stream"
@@ -1163,7 +1163,6 @@ func TestIntegrationGetOk(t *testing.T) {
11631163
}
11641164

11651165
msg, ok, err := ch.Get(queue, false)
1166-
11671166
if err != nil {
11681167
t.Fatalf("Failed get: %v", err)
11691168
}
@@ -1190,7 +1189,6 @@ func TestIntegrationGetEmpty(t *testing.T) {
11901189
}
11911190

11921191
_, ok, err := ch.Get(queue, false)
1193-
11941192
if err != nil {
11951193
t.Fatalf("Failed get: %v", err)
11961194
}
@@ -1260,7 +1258,6 @@ func TestIntegrationTxRollback(t *testing.T) {
12601258
}
12611259

12621260
_, ok, err := ch.Get(queue, false)
1263-
12641261
if err != nil {
12651262
t.Fatalf("Failed get: %v", err)
12661263
}
@@ -1729,7 +1726,6 @@ func TestCorruptedMessageIssue7(t *testing.T) {
17291726
err := pub.PublishWithContext(context.TODO(), "", queue, false, false, Publishing{
17301727
Body: generateCrc32Random(t, 7*i),
17311728
})
1732-
17331729
if err != nil {
17341730
t.Fatalf("Failed to publish")
17351731
}
@@ -2192,7 +2188,6 @@ func TestShouldNotWaitAfterConnectionClosedNewChannelCreatedIssue11(t *testing.T
21922188
if err == nil {
21932189
t.Fatalf("Opening a channel from a closed connection should not block but returning an error %v", err)
21942190
}
2195-
21962191
}
21972192

21982193
// Pulls out the CRC and verifies the remaining content against the CRC

‎log.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ func SetLogger(logger Logging) {
1616
Logger = logger
1717
}
1818

19-
type NullLogger struct {
20-
}
19+
type NullLogger struct{}
2120

2221
func (l NullLogger) Printf(format string, v ...interface{}) {
2322
}

‎spec/gen.go

-2
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,6 @@ func public(parts ...string) string {
502502

503503
func export(delim *regexp.Regexp, parts ...string) (res string) {
504504
for _, in := range parts {
505-
506505
res += delim.ReplaceAllStringFunc(in, func(match string) string {
507506
switch len(match) {
508507
case 1:
@@ -526,7 +525,6 @@ func main() {
526525
}
527526

528527
err = xml.Unmarshal(spec, &r.Root)
529-
530528
if err != nil {
531529
log.Fatalln("Could not parse XML:", err)
532530
}

‎spec091.go

+19-118
Large diffs are not rendered by default.

‎types_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ func TestValidateField(t *testing.T) {
6767
simpleTypes := []interface{}{
6868
nil, true, byte(1), int8(1), 10, int16(10), int32(10), int64(10),
6969
float32(1.0), float64(1.0), "string", []byte("byte slice"),
70-
Decimal{Scale: 2, Value: 12345}, time.Now(),
70+
Decimal{Scale: 2, Value: 12345},
71+
time.Now(),
7172
}
7273
for _, v := range simpleTypes {
7374
if err := validateField(v); err != nil {

‎uri.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ import (
1414
"strings"
1515
)
1616

17-
var errURIScheme = errors.New("AMQP scheme must be either 'amqp://' or 'amqps://'")
18-
var errURIWhitespace = errors.New("URI must not contain whitespace")
17+
var (
18+
errURIScheme = errors.New("AMQP scheme must be either 'amqp://' or 'amqps://'")
19+
errURIWhitespace = errors.New("URI must not contain whitespace")
20+
)
1921

2022
var schemePorts = map[string]int{
2123
"amqp": 5672,

‎write.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ func writeFrame(w io.Writer, typ uint8, channel uint16, payload []byte) (err err
224224
byte((size & 0x0000ff00) >> 8),
225225
byte((size & 0x000000ff) >> 0),
226226
})
227-
228227
if err != nil {
229228
return
230229
}
@@ -243,7 +242,7 @@ func writeFrame(w io.Writer, typ uint8, channel uint16, payload []byte) (err err
243242
func writeShortstr(w io.Writer, s string) (err error) {
244243
b := []byte(s)
245244

246-
var length = uint8(len(b))
245+
length := uint8(len(b))
247246

248247
if err = binary.Write(w, binary.BigEndian, length); err != nil {
249248
return
@@ -259,7 +258,7 @@ func writeShortstr(w io.Writer, s string) (err error) {
259258
func writeLongstr(w io.Writer, s string) (err error) {
260259
b := []byte(s)
261260

262-
var length = uint32(len(b))
261+
length := uint32(len(b))
263262

264263
if err = binary.Write(w, binary.BigEndian, length); err != nil {
265264
return

0 commit comments

Comments
 (0)
Please sign in to comment.