本文整理汇总了Golang中sort.StringSlice.Len方法的典型用法代码示例。如果您正苦于以下问题:Golang StringSlice.Len方法的具体用法?Golang StringSlice.Len怎么用?Golang StringSlice.Len使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sort.StringSlice
的用法示例。
在下文中一共展示了StringSlice.Len方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestKeys
func TestKeys(t *testing.T) {
Convey("Testing Keys()", t, func() {
var keys sort.StringSlice
c := NewConfig(Nodes([]string{"domains", "hosts"}))
So(c.ReadCfg(&CFGstatic{Cfg: tdata.Cfg}), ShouldBeNil)
So(c.sortKeys(), ShouldResemble, sort.StringSlice{"blacklist", "domains", "hosts"})
So(c.GetAll().Names(), ShouldResemble, sort.StringSlice{"includes.[1]", "includes.[9]", "malc0de", "malwaredomains.com", "openphish", "raw.github.com", "simple_tracking", "sysctl.org", "tasty", "volkerschatz", "yoyo", "zeus"})
for _, k := range []string{"a", "b", "c", "z", "q", "s", "e", "i", "x", "m"} {
keys = append(keys, k)
}
So(keys.Len(), ShouldEqual, 10)
})
}
示例2: calcCalls
func (r dynamicImage) calcCalls(source *arrowSlice, func_name string, call_depth uint, buffer *bytes.Buffer, visitedCalls sort.StringSlice) {
for _, v := range *source {
if v.from < func_name {
continue
} else if v.from > func_name {
break
}
buffer.WriteString(v.attr)
buffer.WriteString("\n")
idx := visitedCalls.Search(v.to)
if idx < visitedCalls.Len() && visitedCalls[idx] == v.to {
} else if r.callDepth == 0 || call_depth+1 < r.callDepth {
visitedCalls = append(visitedCalls, v.to)
visitedCalls.Sort()
r.calcCalls(source, v.to, call_depth+1, buffer, visitedCalls)
}
}
}