瀏覽代碼

types: add len func for urlmaps

Xiang Li 10 年之前
父節點
當前提交
b8279b3591
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      pkg/types/urlsmap.go

+ 5 - 1
pkg/types/urlsmap.go

@@ -25,7 +25,7 @@ type URLsMap map[string]URLs
 
 
 // NewURLsMap returns a URLsMap instantiated from the given string,
 // NewURLsMap returns a URLsMap instantiated from the given string,
 // which consists of discovery-formatted names-to-URLs, like:
 // which consists of discovery-formatted names-to-URLs, like:
-// mach0=http://1.1.1.1,mach0=http://2.2.2.2,mach1=http://3.3.3.3,mach2=http://4.4.4.4
+// mach0=http://1.1.1.1:2380,mach0=http://2.2.2.2::2380,mach1=http://3.3.3.3:2380,mach2=http://4.4.4.4:2380
 func NewURLsMap(s string) (URLsMap, error) {
 func NewURLsMap(s string) (URLsMap, error) {
 	cl := URLsMap{}
 	cl := URLsMap{}
 	v, err := url.ParseQuery(strings.Replace(s, ",", "&", -1))
 	v, err := url.ParseQuery(strings.Replace(s, ",", "&", -1))
@@ -69,3 +69,7 @@ func (c URLsMap) URLs() []string {
 	sort.Strings(urls)
 	sort.Strings(urls)
 	return urls
 	return urls
 }
 }
+
+func (c URLsMap) Len() int {
+	return len(c)
+}