本文整理汇总了Golang中github.com/corestoreio/csfw/utils.StringSlice.Append方法的典型用法代码示例。如果您正苦于以下问题:Golang StringSlice.Append方法的具体用法?Golang StringSlice.Append怎么用?Golang StringSlice.Append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/corestoreio/csfw/utils.StringSlice
的用法示例。
在下文中一共展示了StringSlice.Append方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestStringSliceAll
func TestStringSliceAll(t *testing.T) {
l := utils.StringSlice{"c", "a", "z", "b"}
assert.True(t, l.All(func(s string) bool {
return len(s) == 1
}))
l.Append("xx")
assert.False(t, l.All(func(s string) bool {
return len(s) == 1
}))
}
示例2: Human
// Human readable representation of the permissions
func (bits Perm) Human() utils.StringSlice {
var ret utils.StringSlice
var i uint
for i = 0; i < 64; i++ {
bit := ((bits & (1 << i)) != 0)
if bit {
ret.Append(Scope(i).String())
}
}
return ret
}
示例3: Codes
// Codes returns a StringSlice with all website codes
func (ws WebsiteSlice) Codes() utils.StringSlice {
if len(ws) == 0 {
return nil
}
var c utils.StringSlice
for _, w := range ws {
if w != nil {
c.Append(w.Data.Code.String)
}
}
return c
}
示例4: TestStringSliceFilter
func TestStringSliceFilter(t *testing.T) {
l := utils.StringSlice{"All", "Go", "Code", "is"}
rl := l.Filter(func(s string) bool {
return s == "Go"
}).ToString()
assert.EqualValues(t, []string{"Go"}, rl)
assert.Len(t, l, 4)
l.Append("incredible", "easy", ",", "sometimes")
assert.Len(t, l, 8)
assert.EqualValues(t, []string{"Go"}, rl)
}
示例5: Codes
// Codes returns a StringSlice with all store codes
func (s TableStoreSlice) Codes() utils.StringSlice {
if len(s) == 0 {
return nil
}
var c utils.StringSlice
for _, store := range s {
if store != nil {
c.Append(store.Code.String)
}
}
return c
}
示例6: TestStringSlice
func TestStringSlice(t *testing.T) {
l := utils.StringSlice{"Maybe", "GoLang", "should", "have", "generics", "but", "who", "needs", "them", "?", ";-)"}
assert.Len(t, l, l.Len())
assert.Equal(t, 1, l.Index("GoLang"))
assert.Equal(t, -1, l.Index("Golang"))
assert.True(t, l.Include("GoLang"))
assert.False(t, l.Include("Golang"))
l2 := utils.StringSlice{"Maybe", "GoLang"}
l2.Map(func(s string) string {
return s + "2"
})
assert.Equal(t, []string{"Maybe2", "GoLang2"}, l2.ToString())
l2.Append("will", "be")
assert.Equal(t, []string{"Maybe2", "GoLang2", "will", "be"}, l2.ToString())
}
示例7: getImportPaths
func getImportPaths() []string {
var paths utils.StringSlice
var getPath = func(s string) string {
ps, err := codegen.ExtractImportPath(s)
codegen.LogFatal(err)
return ps
}
for _, et := range codegen.ConfigEntityType {
paths.Append(
getPath(et.EntityModel),
getPath(et.AttributeModel),
getPath(et.EntityTable),
getPath(et.IncrementModel),
getPath(et.AdditionalAttributeTable),
getPath(et.EntityAttributeCollection),
)
}
return paths.Unique().ToString()
}