devicepath/utils.go

19 lines
393 B
Go
Raw Permalink Normal View History

2023-08-27 13:09:30 +00:00
package devicepath
import "strings"
func getPrefix(raw string) string {
firstCharAfterId := strings.Index(raw, "(")
if firstCharAfterId == -1 {
return ""
}
return raw[0:firstCharAfterId]
}
func checkStringFormat(raw, prefix string, length int) bool {
if length > 0 && len(raw) != length {
return false
}
return strings.HasPrefix(raw, prefix+"(") && strings.HasSuffix(raw, ")")
}