mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
exchanges/refactor: Use strings.Builder for string construction (#2046)
* refactor: use strings.builder Signed-off-by: keeghcet <keeghcet@outlook.com> * Apply suggestion from @shazbert Co-authored-by: Ryan O'Hara-Reid <oharareid.ryan@gmail.com> --------- Signed-off-by: keeghcet <keeghcet@outlook.com> Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> Co-authored-by: Ryan O'Hara-Reid <oharareid.ryan@gmail.com>
This commit is contained in:
@@ -425,11 +425,12 @@ func orderbookChecksum(ob *orderbook.Book) uint32 {
|
||||
|
||||
// concatOrderbookLiquidity concatenates price and amounts together for checksum processing
|
||||
func concatOrderbookLiquidity(liquidity orderbook.Levels) string {
|
||||
var c string
|
||||
var c strings.Builder
|
||||
for x := range min(10, len(liquidity)) {
|
||||
c += trim(liquidity[x].Price) + trim(liquidity[x].Amount)
|
||||
c.WriteString(trim(liquidity[x].Price))
|
||||
c.WriteString(trim(liquidity[x].Amount))
|
||||
}
|
||||
return c
|
||||
return c.String()
|
||||
}
|
||||
|
||||
// trim turns value into string, removes the decimal point and all the leading zeros
|
||||
|
||||
@@ -2593,16 +2593,16 @@ func (e *Exchange) SendAuthHTTPRequestV5(ctx context.Context, ePath exchange.URL
|
||||
return fmt.Errorf("%w code: %d message: %s", request.ErrAuthRequestFailed, response.RetCode, response.RetMsg)
|
||||
}
|
||||
if len(response.RetExtInfo.List) > 0 && response.RetCode != 0 {
|
||||
var errMessage string
|
||||
var errMessage strings.Builder
|
||||
var failed bool
|
||||
for i := range response.RetExtInfo.List {
|
||||
if response.RetExtInfo.List[i].Code != 0 {
|
||||
failed = true
|
||||
errMessage += fmt.Sprintf("code: %d message: %s ", response.RetExtInfo.List[i].Code, response.RetExtInfo.List[i].Message)
|
||||
errMessage.WriteString(fmt.Sprintf("code: %d message: %s ", response.RetExtInfo.List[i].Code, response.RetExtInfo.List[i].Message))
|
||||
}
|
||||
}
|
||||
if failed {
|
||||
return fmt.Errorf("%w %s", request.ErrAuthRequestFailed, errMessage)
|
||||
return fmt.Errorf("%w %s", request.ErrAuthRequestFailed, errMessage.String())
|
||||
}
|
||||
}
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user