Refactor: func StringInSlice to slices.Contains (#24262)
* Refactor: Use generic to change func StringInSlice to Contains * Refactor: Use generic to change func stringNotInSlice to Contains Make utils.go (dir server/public/utils) and func Contains * Refactor: Move func Contains from channels/utils to public/utils Move func Contains from channels/utils to public/utils Fix import declarations line * Docs: Add a description of the Contains function * Test: add TestContains Add a test code for a Contain function
Этот коммит содержится в:
@@ -19,7 +19,6 @@ import (
|
||||
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/printer"
|
||||
|
||||
"github.com/mattermost/mattermost/server/v8/channels/app/imports"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/utils"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
pUtils "github.com/mattermost/mattermost/server/public/utils"
|
||||
@@ -362,7 +361,7 @@ func sampledataCmdF(c client.Client, command *cobra.Command, args []string) erro
|
||||
totalUsers := 3 + rand.Intn(3)
|
||||
for len(users) < totalUsers {
|
||||
user := allUsers[rand.Intn(len(allUsers))]
|
||||
if !utils.StringInSlice(user, users) {
|
||||
if !pUtils.Contains(users, user) {
|
||||
users = append(users, user)
|
||||
}
|
||||
}
|
||||
@@ -377,7 +376,7 @@ func sampledataCmdF(c client.Client, command *cobra.Command, args []string) erro
|
||||
totalUsers := 3 + rand.Intn(3)
|
||||
for len(users) < totalUsers {
|
||||
user := allUsers[rand.Intn(len(allUsers))]
|
||||
if !utils.StringInSlice(user, users) {
|
||||
if !pUtils.Contains(users, user) {
|
||||
users = append(users, user)
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user