// BenchmarkUnique 2000000 612 ns/op 160 B/op 2 allocs/op func BenchmarkStringSliceUnique(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { l := utils.StringSlice{"Maybe", "GoLang", "GoLang", "GoLang", "or", "or", "RostLang", "RostLang"} l.Unique() benchStringSliceUnique = l } }
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() }
func TestStringSliceUnique(t *testing.T) { l := utils.StringSlice{"Maybe", "GoLang", "GoLang", "GoLang", "or", "or", "RostLang", "RostLang"} assert.Equal(t, []string{"Maybe", "GoLang", "or", "RostLang"}, l.Unique().ToString()) }