mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
20 lines
405 B
Go
20 lines
405 B
Go
|
package netutil
|
||
|
|
||
|
import (
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
// ParseGroupAddr parses `groupID/addrX` addr and returns (groupID, addrX).
|
||
|
//
|
||
|
// If addr doesn't contain `groupID/` prefix, then ("", addr) is returned.
|
||
|
func ParseGroupAddr(addr string) (string, string) {
|
||
|
n := strings.IndexByte(addr, '/')
|
||
|
if n < 0 {
|
||
|
return "", addr
|
||
|
}
|
||
|
if strings.HasPrefix(addr, "file:") {
|
||
|
return "", addr
|
||
|
}
|
||
|
return addr[:n], addr[n+1:]
|
||
|
}
|