mirror of
https://gitee.com/willfree/mlsr.git
synced 2026-10-04 19:42:02 +08:00
31 lines
830 B
Go
31 lines
830 B
Go
// Package utils
|
|
// @Author: Wang Feng
|
|
// @Description:
|
|
// @Version: 0.1.0
|
|
// @Date: 2022/7/29 21:59
|
|
// @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
|
//
|
|
|
|
package utils
|
|
|
|
import "minlib/component"
|
|
|
|
//
|
|
// GetNameComponentPosition
|
|
// @Description: 从名称中获取指定字符串所属位置
|
|
// @param name
|
|
// @param searchString
|
|
// @return int 如果没找到该字符串,返回-1
|
|
//
|
|
func GetNameComponentPosition(name *component.Identifier, searchString string) int {
|
|
components := name.GetComponents()
|
|
for i := 0; i < len(components); i++ {
|
|
// bug: IdentifierComponent.ToUri() 默认不带斜杠
|
|
// if components[i].ToUri() == "/"+searchString {
|
|
if components[i].ToUri() == searchString {
|
|
return i
|
|
}
|
|
}
|
|
return -1
|
|
}
|