// SplitAddressToURI acts like SplitAddress but returns an URI struct instead.
496660
func SplitAddressToURI(addressString string, defaultProtocol string) (uri URI, err error) {
	portString := ""
	uri.Protocol, uri.Address, portString, err = SplitAddress(addressString, defaultProtocol)
	portNum, _ := strconv.ParseInt(portString, 10, 16)
	uri.Port = uint16(portNum)
	return uri, err
}
723984
func splitEmail(email string) (local string, domain string, ok bool) {
	parts := strings.Split(email, "@")
	if len(parts) < 2 {
		return
	}
	local = parts[0]
	domain = parts[1]
	// Check that the parts contain enough characters.
	if len(local) < 1 {
		return
	}
	if len(domain) < len("x.xx") {
		return
	}
	return local, domain, true
}
833389
func (id *SpiffeIDService) URI() *url.URL {
	var result url.URL
	result.Scheme = "spiffe"
	result.Host = id.Host
	result.Path = fmt.Sprintf("/ns/%s/dc/%s/svc/%s",
		id.Namespace, id.Datacenter, id.Service)
	return &result
}
830470
func addressToURLs(addr string, isTLS bool) []string {
	addrs := strings.Split(addr, ",")
	for i := range addrs {
		if strings.HasPrefix(addrs[i], "unix://") || strings.HasPrefix(addrs[i], "unixs://") {
			continue
		}
		if isTLS {
			addrs[i] = "https://" + addrs[i]
		} else {
			addrs[i] = "http://" + addrs[i]
		}
	}
	return addrs
}
197400
func splitHostnamePartsFromHost(fullHost string, defaultPortNum string) (string, string) {

	h := strings.Split(fullHost, ":")

	if len(h) == 2 {
		return h[0], h[1]
	}

	return h[0], defaultPortNum
}
1213983
func NormalizeAddress(addr string, defaultPort uint16) string {
	_, _, err := net.SplitHostPort(addr)
	if err != nil {
		return net.JoinHostPort(addr, strconv.Itoa(int(defaultPort)))
	}
	return addr
}
1231373
func SplitHostMaybePort(hostport string) HostMaybePort {
	host, portStr, err := net.SplitHostPort(hostport)
	if err != nil {
		if strings.Contains(err.Error(), "missing port") {
			return HostMaybePort{
				Host:   hostport,
				NoPort: true,
			}
		}
		return HostMaybePort{
			Err: err,
		}
	}
	portI64, err := strconv.ParseInt(portStr, 0, 0)
	if err != nil {
		return HostMaybePort{
			Host: host,
			Port: -1,
			Err:  err,
		}
	}
	return HostMaybePort{
		Host: host,
		Port: int(portI64),
	}
}
577686
func (d *Domain) MigrateToURI3(dconnuri string, params *DomainMigrateParameters, flags DomainMigrateFlags) error {
	var cdconnuri *C.char
	if dconnuri != "" {
		cdconnuri = C.CString(dconnuri)
		defer C.free(unsafe.Pointer(cdconnuri))
	}

	info := getMigrateParameterFieldInfo(params)
	cparams, cnparams, gerr := typedParamsPackNew(info)
	if gerr != nil {
		return gerr
	}

	defer C.virTypedParamsFree(cparams, cnparams)

	var err C.virError
	ret := C.virDomainMigrateToURI3Wrapper(d.ptr, cdconnuri, cparams, C.uint(cnparams), C.uint(flags), &err)
	if ret == -1 {
		return makeError(&err)
	}

	return nil
}
1146439
func SplitPathDirEntry(path string) (dir, base string) {
	cleanedPath := filepath.Clean(filepath.FromSlash(path))

	if specifiesCurrentDir(path) {
		cleanedPath += string(os.PathSeparator) + "."
	}

	return filepath.Dir(cleanedPath), filepath.Base(cleanedPath)
}
164780
func (c *Cluster) SplitIndex(mvccStore MVCCStore, tableID, indexID int64, count int) {
	indexStart := tablecodec.EncodeTableIndexPrefix(tableID, indexID)
	indexEnd := indexStart.PrefixNext()
	c.splitRange(mvccStore, NewMvccKey(indexStart), NewMvccKey(indexEnd), count)
}
627028
func FirstUri(baseUriList string, separator string) string {
	if separator != "" {
		slist := strings.Split(baseUriList, separator)
		if len(slist) > 0 {
			return slist[0]
		}
	} else {
		return baseUriList
	}

	return ""
}
372561
func splitAddr(addr string) (string, string, string, error) {
	scheme, hostPort := splitScheme(addr)
	host, port := "", ""
	if hostPort != "" {
		var err error
		host, port, err = net.SplitHostPort(hostPort)
		if err != nil {
			return "", "", "", errors.Wrapf(err, "splitting host port: %s", hostPort)
		}
	}
	// It's not ideal to have a default here, but the alterative
	// results in a port of 0, which causes Pilosa to listen on
	// a random port.
	if port == "" {
		port = "10101"
	}
	return scheme, host, port, nil
}
789884
func (g *graphObject) Uri(s string) quad.IRI {
	return quad.IRI(g.s.ns.FullIRI(s))
}
894272
func (r *Registration) URI() string {
	return fmt.Sprintf("%s.%s", r.Type, r.ID)
}
1108521
func splitHostPort(host string) (string, string) {
	ix := strings.LastIndex(host, ":")

	if ix <= strings.LastIndex(host, "]") {
		return host, ""
	}

	name := host[:ix]
	port := host[ix+1:]

	return name, port
}
1297611
func (splitter *Splitter) Split() ([]*querypb.QuerySplit, error) {
	var boundaries []tuple
	var err error
	boundaries, err = splitter.algorithm.generateBoundaries()
	if err != nil {
		return nil, err
	}
	boundaries = append(boundaries, nil)
	splits := []*querypb.QuerySplit{}
	var start tuple
	for _, end := range boundaries {
		splits = append(splits, splitter.constructQueryPart(start, end))
		start = end
	}
	return splits, nil
}
1272841
func NormalizeAddress(addr string, defaultPort string) (hostport string, err error) {
	// If the first SplitHostPort errors because of a missing port and not
	// for an invalid host, add the port.  If the second SplitHostPort
	// fails, then a port is not missing and the original error should be
	// returned.
	host, port, origErr := net.SplitHostPort(addr)
	if origErr == nil {
		return net.JoinHostPort(host, port), nil
	}
	addr = net.JoinHostPort(addr, defaultPort)
	_, _, err = net.SplitHostPort(addr)
	if err != nil {
		return "", origErr
	}
	return addr, nil
}