mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* 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
15 lines
321 B
Go
15 lines
321 B
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package utils
|
|
|
|
// Contains returns true if the slice contains the item.
|
|
func Contains[T comparable](slice []T, item T) bool {
|
|
for _, s := range slice {
|
|
if s == item {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|