Beispiel #1
0
// BenchmarkStringSliceUnique	 2000000	       612 ns/op	     160 B/op	       2 allocs/op <- Go 1.4.2
// BenchmarkStringSliceUnique  	10000000	       179 ns/op	     128 B/op	       1 allocs/op <- Go 1.5
func BenchmarkStringSliceUnique(b *testing.B) {
	b.ReportAllocs()
	for i := 0; i < b.N; i++ {
		l := util.StringSlice{"Maybe", "GoLang", "GoLang", "GoLang", "or", "or", "RostLang", "RostLang"}
		l.Unique()
		benchStringSliceUnique = l
	}
}
Beispiel #2
0
func getImportPaths() []string {
	var paths util.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()
}
Beispiel #3
0
func TestStringSliceUnique(t *testing.T) {
	l := util.StringSlice{"Maybe", "GoLang", "GoLang", "GoLang", "or", "or", "RostLang", "RostLang"}
	assert.Equal(t, []string{"Maybe", "GoLang", "or", "RostLang"}, l.Unique().ToString())
}