Skip to content

Commit a39f237

Browse files
committed
Use fmt.Errorf
1 parent f7c96c9 commit a39f237

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

rabbitmq_amqp/common.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ const (
2121
commandReplyTo = "$me"
2222
managementNodeAddress = "/management"
2323
linkPairName = "management-link-pair"
24-
exchanges = "exchanges"
25-
key = "key"
26-
queues = "queues"
27-
bindings = "bindings"
24+
exchanges = "exchanges"
25+
key = "key"
26+
queues = "queues"
27+
bindings = "bindings"
2828
)
2929

3030
// encodePathSegments takes a string and returns its percent-encoded representation.

rabbitmq_amqp/converters.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package rabbitmq_amqp
22

33
import (
4-
"errors"
54
"fmt"
65
"regexp"
76
"strconv"
@@ -47,7 +46,7 @@ func CapacityFrom(value string) (int64, error) {
4746
match, err := regexp.Compile("^((kb|mb|gb|tb))")
4847
if err != nil {
4948
return 0,
50-
errors.New(fmt.Sprintf("Capacity, invalid unit size format:%s", value))
49+
fmt.Errorf("Capacity, invalid unit size format:%s", value)
5150
}
5251

5352
foundUnitSize := strings.ToLower(value[len(value)-2:])
@@ -56,7 +55,7 @@ func CapacityFrom(value string) (int64, error) {
5655

5756
size, err := strconv.Atoi(value[:len(value)-2])
5857
if err != nil {
59-
return 0, errors.New(fmt.Sprintf("Capacity, Invalid number format: %s", value))
58+
return 0, fmt.Errorf("Capacity, Invalid number format: %s", value)
6059
}
6160
switch foundUnitSize {
6261
case UnitKb:
@@ -71,9 +70,7 @@ func CapacityFrom(value string) (int64, error) {
7170
case UnitTb:
7271
return CapacityTB(int64(size)), nil
7372
}
74-
7573
}
7674

77-
return 0,
78-
errors.New(fmt.Sprintf("Capacity, Invalid unit size format: %s", value))
75+
return 0, fmt.Errorf("Capacity, Invalid unit size format: %s", value)
7976
}

0 commit comments

Comments
 (0)