logs-analyzer/signoz/pkg/query-service/utils/port.go
2024-09-02 22:47:30 +03:00

22 lines
331 B
Go

package utils
import (
"net"
"strconv"
)
// GetPort returns the port of an endpoint address.
func GetPort(addr net.Addr) (int, error) {
_, port, err := net.SplitHostPort(addr.String())
if err != nil {
return -1, err
}
parsedPort, err := strconv.Atoi(port)
if err != nil {
return -1, err
}
return parsedPort, nil
}