From: Jeff Halter Date: Thu, 20 Apr 2023 00:53:28 +0000 (-0700) Subject: Use strings.ReplaceAll method X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/commitdiff_plain/c8bfd6061f5079f6c6c0155a2de1e8cd32d8a39a Use strings.ReplaceAll method --- diff --git a/hotline/client_conn.go b/hotline/client_conn.go index f92c1cd..0a5a108 100644 --- a/hotline/client_conn.go +++ b/hotline/client_conn.go @@ -254,5 +254,5 @@ func (cc *ClientConn) String() string { "None.\n", ) - return strings.Replace(template, "\n", "\r", -1) + return strings.ReplaceAll(template, "\n", "\r") } diff --git a/hotline/files.go b/hotline/files.go index 9c3efe2..63fa482 100644 --- a/hotline/files.go +++ b/hotline/files.go @@ -117,7 +117,7 @@ func getFileNameList(path string, ignoreList []string) (fields []Field, err erro copy(fnwi.Creator[:], hlFile.ffo.FlatFileInformationFork.CreatorSignature) } - strippedName := strings.Replace(file.Name(), ".incomplete", "", -1) + strippedName := strings.ReplaceAll(file.Name(), ".incomplete", "") nameSize := make([]byte, 2) binary.BigEndian.PutUint16(nameSize, uint16(len(strippedName))) diff --git a/hotline/transaction_handlers.go b/hotline/transaction_handlers.go index 137b2a0..7864e19 100644 --- a/hotline/transaction_handlers.go +++ b/hotline/transaction_handlers.go @@ -1015,7 +1015,7 @@ func HandleTranOldPostNews(cc *ClientConn, t *Transaction) (res []Transaction, e } newsPost := fmt.Sprintf(newsTemplate+"\r", cc.UserName, time.Now().Format(newsDateTemplate), t.GetField(FieldData).Data) - newsPost = strings.Replace(newsPost, "\n", "\r", -1) + newsPost = strings.ReplaceAll(newsPost, "\n", "\r") // update news in memory cc.Server.FlatNews = append([]byte(newsPost), cc.Server.FlatNews...) diff --git a/hotline/transaction_handlers_test.go b/hotline/transaction_handlers_test.go index ff1a53c..01880f2 100644 --- a/hotline/transaction_handlers_test.go +++ b/hotline/transaction_handlers_test.go @@ -2980,7 +2980,7 @@ func TestHandleGetClientInfoText(t *testing.T) { ErrorCode: []byte{0, 0, 0, 0}, Fields: []Field{ NewField(FieldData, []byte( - strings.Replace(`Nickname: Testy McTest + strings.ReplaceAll(`Nickname: Testy McTest Name: test Account: test Address: 1.2.3.4:12345 @@ -3005,7 +3005,7 @@ None. None. -`, "\n", "\r", -1)), +`, "\n", "\r")), ), NewField(FieldUserName, []byte("Testy McTest")), },