1 Star 0 Fork 0

iceinto/gfutil

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gstr_array.go 938 Bytes
一键复制 编辑 原始数据 按行查看 历史
iceinto 提交于 2024-09-13 17:50 . v2 版本位置调整
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/elastic/beats/v7/kspkg/gf.
package gstr
// SearchArray searches string `s` in string slice `a` case-sensitively,
// returns its index in `a`.
// If `s` is not found in `a`, it returns -1.
func SearchArray(a []string, s string) int {
for i, v := range a {
if s == v {
return i
}
}
return NotFoundIndex
}
// InArray checks whether string `s` in slice `a`.
func InArray(a []string, s string) bool {
return SearchArray(a, s) != NotFoundIndex
}
// PrefixArray adds `prefix` string for each item of `array`.
//
// Example:
// PrefixArray(["a","b"], "gf_") -> ["gf_a", "gf_b"]
func PrefixArray(array []string, prefix string) {
for k, v := range array {
array[k] = prefix + v
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/iceinto/gfutil.git
git@gitee.com:iceinto/gfutil.git
iceinto
gfutil
gfutil
v2.0.0

搜索帮助