func NewURL(urlString string, opts ...Option) (*URL, error) {
	s := URL{baseURL: baseURL{}}
	if urlString == "" {
		return &s, nil
	}
	rawURLString, err := url.QueryUnescape(urlString)
	if err != nil {
		return &s, perrors.Errorf("URL.QueryUnescape(%s),  error{%v}", urlString, err)
	}
	if !strings.Contains(rawURLString, "//") {
		t := URL{baseURL: baseURL{}}
		for _, opt := range opts {
			opt(&t)
		}
		rawURLString = t.Protocol + "://" + rawURLString
	}
	serviceURL, urlParseErr := url.Parse(rawURLString)
	if urlParseErr != nil {
		return &s, perrors.Errorf("URL.Parse(URL string{%s}),  error{%v}", rawURLString, err)
	}
	s.params, err = url.ParseQuery(serviceURL.RawQuery)
	if err != nil {
		return &s, perrors.Errorf("URL.ParseQuery(raw URL string{%s}),  error{%v}", serviceURL.RawQuery, err)
	}
	s.PrimitiveURL = urlString
	s.Protocol = serviceURL.Scheme
	s.Username = serviceURL.User.Username()
	s.Password, _ = serviceURL.User.Password()
	s.Location = serviceURL.Host
	s.Path = serviceURL.Path
	for _, location := range strings.Split(s.Location, ",") {
		if strings.Contains(location, ":") {
			s.Ip, s.Port, err = net.SplitHostPort(location)
			if err != nil {
				return &s, perrors.Errorf("net.SplitHostPort(url.Host{%s}), error{%v}", s.Location, err)
			}
			break
		}
	}
	for _, opt := range opts {
		opt(&s)
	}
	return &s, nil
}
NewURL will create a new URL
the urlString should not be empty
package common
import (
	"bytes"
	"encoding/base64"
	"fmt"
	"math"
	"net"
	"net/url"
	"strconv"
	"strings"
	"sync"
	"time"
)
import (
	cm "github.com/Workiva/go-datastructures/common"
	gxset "github.com/dubbogo/gost/container/set"
	"github.com/jinzhu/copier"
	perrors "github.com/pkg/errors"
	"github.com/satori/go.uuid"
)
import (
	"dubbo.apache.org/dubbo-go/v3/common/constant"
)
const (
	CONSUMER = iota
	CONFIGURATOR
	ROUTER
	PROVIDER
	PROTOCOL = "protocol"
)
var (
	DubboNodes = [...]string{"consumers", "configurators", "routers", "providers"}
	DubboRole = [...]string{"consumer", "", "routers", "provider"}
	compareURLEqualFunc CompareURLEqualFunc
)
func init() {
	compareURLEqualFunc = defaultCompareURLEqual
}
type RoleType int
func (t RoleType) String() string {
	return DubboNodes[t]
}
func (t RoleType) Role() string {
	return DubboRole[t]
}
type baseURL struct {
	Protocol string
	Location string  
	Ip       string
	Port     string
	PrimitiveURL string
}
type noCopy struct{}
func (*noCopy) Lock()   {}
func (*noCopy) Unlock() {}
type URL struct {
	noCopy noCopy
	baseURL
	paramsLock sync.RWMutex
	params     url.Values
	Path     string  
	Username string
	Password string
	Methods  []string
	SubURL *URL
}
func (c *URL) JavaClassName() string {
	return "org.apache.dubbo.common.URL"
}
type Option func(*URL)
func WithUsername(username string) Option {
	return func(url *URL) {
		url.Username = username
	}
}
func WithPassword(pwd string) Option {
	return func(url *URL) {
		url.Password = pwd
	}
}
func WithMethods(methods []string) Option {
	return func(url *URL) {
		url.Methods = methods
	}
}
func WithParams(params url.Values) Option {
	return func(url *URL) {
		url.params = params
	}
}
func WithParamsValue(key, val string) Option {
	return func(url *URL) {
		url.SetParam(key, val)
	}
}
func WithProtocol(proto string) Option {
	return func(url *URL) {
		url.Protocol = proto
	}
}
func WithIp(ip string) Option {
	return func(url *URL) {
		url.Ip = ip
	}
}
func WithPort(port string) Option {
	return func(url *URL) {
		url.Port = port
	}
}
func WithPath(path string) Option {
	return func(url *URL) {
		url.Path = "/" + strings.TrimPrefix(path, "/")
	}
}
func WithLocation(location string) Option {
	return func(url *URL) {
		url.Location = location
	}
}
func WithToken(token string) Option {
	return func(url *URL) {
		if len(token) > 0 {
			value := token
			if strings.ToLower(token) == "true" || strings.ToLower(token) == "default" {
				u := uuid.NewV4()
				value = u.String()
			}
			url.SetParam(constant.TOKEN_KEY, value)
		}
	}
}
func NewURLWithOptions(opts ...Option) *URL {
	newURL := &URL{}
	for _, opt := range opts {
		opt(newURL)
	}
	newURL.Location = newURL.Ip + ":" + newURL.Port
	return newURL
}