Applies perfsprint linter (#24999)
Replacing usages of fmt.Sprint with faster alternatives Signed-off-by: Philippe Antoine <contact@catenacyber.fr>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
43f4734eae
Коммит
04e7b6bc9e
@@ -7,9 +7,9 @@ import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -180,7 +180,7 @@ func selfHostedConfirm(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
c.App.NotifySelfHostedSignupProgress(confirmResponse.Progress, user.Id)
|
||||
}
|
||||
|
||||
if err.Error() == fmt.Sprintf("%d", http.StatusUnprocessableEntity) {
|
||||
if err.Error() == strconv.Itoa(http.StatusUnprocessableEntity) {
|
||||
c.Err = model.NewAppError(where, "api.cloud.app_error", nil, "", http.StatusUnprocessableEntity).Wrap(err)
|
||||
return
|
||||
}
|
||||
@@ -365,7 +365,7 @@ func selfHostedConfirmExpand(c *Context, w http.ResponseWriter, r *http.Request)
|
||||
c.App.NotifySelfHostedSignupProgress(confirmResponse.Progress, user.Id)
|
||||
}
|
||||
|
||||
if err.Error() == fmt.Sprintf("%d", http.StatusUnprocessableEntity) {
|
||||
if err.Error() == strconv.Itoa(http.StatusUnprocessableEntity) {
|
||||
c.Err = model.NewAppError(where, "api.cloud.app_error", nil, "", http.StatusUnprocessableEntity).Wrap(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"html"
|
||||
"html/template"
|
||||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -343,9 +344,9 @@ func getFormattedPostTime(user *model.User, post *model.Post, useMilitaryTime bo
|
||||
|
||||
return formattedPostTime{
|
||||
Time: localTime,
|
||||
Year: fmt.Sprintf("%d", localTime.Year()),
|
||||
Year: strconv.Itoa(localTime.Year()),
|
||||
Month: translateFunc(localTime.Month().String()),
|
||||
Day: fmt.Sprintf("%d", localTime.Day()),
|
||||
Day: strconv.Itoa(localTime.Day()),
|
||||
Hour: hour,
|
||||
Minute: fmt.Sprintf("%02d"+period, localTime.Minute()),
|
||||
TimeZone: zone,
|
||||
|
||||
@@ -5,6 +5,7 @@ package platform
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
@@ -229,7 +230,7 @@ func (ps *PlatformService) UpdateSessionsIsGuest(c request.CTX, userID string, i
|
||||
}
|
||||
|
||||
for _, session := range sessions {
|
||||
session.AddProp(model.SessionPropIsGuest, fmt.Sprintf("%t", isGuest))
|
||||
session.AddProp(model.SessionPropIsGuest, strconv.FormatBool(isGuest))
|
||||
err := ps.Store.Session().UpdateProps(session)
|
||||
if err != nil {
|
||||
mlog.Warn("Unable to update isGuest session", mlog.Err(err))
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
package searchtest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -352,7 +352,7 @@ func (th *SearchTestHelper) createPostModel(userID, channelID, message, hashtags
|
||||
return &model.Post{
|
||||
Message: message,
|
||||
ChannelId: channelID,
|
||||
PendingPostId: model.NewId() + ":" + fmt.Sprint(model.GetMillis()),
|
||||
PendingPostId: model.NewId() + ":" + strconv.FormatInt(model.GetMillis(), 10),
|
||||
UserId: userID,
|
||||
Hashtags: hashtags,
|
||||
IsPinned: pinned,
|
||||
|
||||
@@ -5,12 +5,12 @@ package utils
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"encoding/hex"
|
||||
)
|
||||
|
||||
func HashSha256(text string) string {
|
||||
hash := sha256.New()
|
||||
hash.Write([]byte(text))
|
||||
|
||||
return fmt.Sprintf("%x", hash.Sum(nil))
|
||||
return hex.EncodeToString(hash.Sum(nil))
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user