bench_helper_test.go7
1:1format
bench_helper_test.go:1:1
package mapset- Fix (safe): run `strider fmt bench_helper_test.go`
1:9package-directory-mismatch
bench_helper_test.go:1:9
package mapset16:28flag-parameter
bench_helper_test.go:16:28
func buildRandomSet(n int, safe bool) Set[int] { if safe {19:4no-else-after-return
bench_helper_test.go:19:4
return NewSet(nrand(n)...) } else { return NewThreadUnsafeSet(nrand(n)...)24:27flag-parameter
bench_helper_test.go:24:27
func buildCaseName(n int, safe bool) string { var settype string35:1top-level-declaration-order
bench_helper_test.go:35:1
type benchCase struct { n int41:2slice-preallocation
bench_helper_test.go:41:2
func buildBenchCases(ns ...int) []benchCase { cases := []benchCase{} for _, n := range ns {bench_test.go7
1:1file-length-limit
bench_test.go:1:1
/*Open Source Initiative OSI - The MIT License (MIT):Licensing1:1format
bench_test.go:1:1
/*Open Source Initiative OSI - The MIT License (MIT):Licensing- Fix (safe): run `strider fmt bench_test.go`
26:9package-directory-mismatch
bench_test.go:26:9
package mapset262:6cognitive-complexity
bench_test.go:262:6
// In this scenario, Contains argument escapes to the heap, while ContainsOne does not.func benchContainsComparison(b *testing.B, n int, s Set[int]) { nums := nrand(n)543:33redundant-conversion
bench_test.go:543:33
func benchIntersect(b *testing.B, n int, s, t Set[int]) { nums := nrand(int(float64(n) * float64(1.5))) for _, v := range nums[:n] {582:33redundant-conversion
bench_test.go:582:33
func benchSymmetricDifference(b *testing.B, n int, s, t Set[int]) { nums := nrand(int(float64(n) * float64(1.5))) for _, v := range nums[:n] {836:12discarded-error-result
bench_test.go:836:12
for i := 0; i < b.N; i++ { _, _ = s.MarshalJSON() }helper.go6
3:9package-comments
helper.go:3:9
package mapset3:9package-directory-mismatch
helper.go:3:9
package mapset5:37nested-structs
helper.go:5:37
func mapclone[T comparable](m map[T]struct{}) map[T]struct{} { c := make(map[T]struct{}, len(m))5:53nested-structs
helper.go:5:53
func mapclone[T comparable](m map[T]struct{}) map[T]struct{} { c := make(map[T]struct{}, len(m))6:18nested-structs
helper.go:6:18
func mapclone[T comparable](m map[T]struct{}) map[T]struct{} { c := make(map[T]struct{}, len(m)) for k := range m {8:10nested-structs
helper.go:8:10
for k := range m { c[k] = struct{}{} }helper_1_21.go4
3:9package-comments
helper_1_21.go:3:9
package mapset3:9package-directory-mismatch
helper_1_21.go:3:9
package mapset7:37nested-structs
helper_1_21.go:7:37
func mapclone[T comparable](m map[T]struct{}) map[T]struct{} { return maps.Clone(m)7:53nested-structs
helper_1_21.go:7:53
func mapclone[T comparable](m map[T]struct{}) map[T]struct{} { return maps.Clone(m)iterator.go6
26:9package-comments
iterator.go:26:9
package mapset26:9package-directory-mismatch
iterator.go:26:9
package mapset30:6exported-declaration-comment
iterator.go:30:6
// elements.type Iterator[T comparable] struct { C <-chan T32:12nested-structs
iterator.go:32:12
C <-chan T stop chan struct{}}51:66nested-structs
iterator.go:51:66
// newIterator returns a new Iterator instance together with its item and stop channels.func newIterator[T comparable]() (*Iterator[T], chan<- T, <-chan struct{}) { itemChan := make(chan T)53:24nested-structs
iterator.go:53:24
itemChan := make(chan T) stopChan := make(chan struct{}) return &Iterator[T]{iterator_example_test.go4
1:1format
iterator_example_test.go:1:1
/*Open Source Initiative OSI - The MIT License (MIT):Licensing- Fix (safe): run `strider fmt iterator_example_test.go`
26:9package-directory-mismatch
iterator_example_test.go:26:9
package mapset36:6test-parallelism
iterator_example_test.go:36:6
func Test_ExampleIterator(t *testing.T) {57:35add-constant
iterator_example_test.go:57:35
if found == nil || found.name != "John" { t.Fatalf("expected iterator to have found `John` record but got nil or something else")set.go16
36:9package-directory-mismatch
set.go:36:9
// that can enforce mutual exclusion through other means.package mapset43:6exported-declaration-comment
set.go:43:6
// operations that can be applied to that set.type Set[T comparable] interface { // Add adds an element to the set. Returns whether43:24interface-method-limit
set.go:43:24
// operations that can be applied to that set.type Set[T comparable] interface { // Add adds an element to the set. Returns whether228:6constructor-interface-return
set.go:228:6
// Operations on the resulting set are thread-safe.func NewSet[T comparable](vs ...T) Set[T] { s := newThreadSafeSetWithSize[T](len(vs))228:6exported-declaration-comment
set.go:228:6
// Operations on the resulting set are thread-safe.func NewSet[T comparable](vs ...T) Set[T] { s := newThreadSafeSetWithSize[T](len(vs))236:6constructor-interface-return
set.go:236:6
// capacity. Operations on the resulting set are thread-safe.func NewSetWithSize[T comparable](cardinality int) Set[T] { return newThreadSafeSetWithSize[T](cardinality)236:6exported-declaration-comment
set.go:236:6
// capacity. Operations on the resulting set are thread-safe.func NewSetWithSize[T comparable](cardinality int) Set[T] { return newThreadSafeSetWithSize[T](cardinality)242:6constructor-interface-return
set.go:242:6
// Operations on the resulting set are not thread-safe.func NewThreadUnsafeSet[T comparable](vs ...T) Set[T] { s := newThreadUnsafeSetWithSize[T](len(vs))242:6exported-declaration-comment
set.go:242:6
// Operations on the resulting set are not thread-safe.func NewThreadUnsafeSet[T comparable](vs ...T) Set[T] { s := newThreadUnsafeSetWithSize[T](len(vs))250:6constructor-interface-return
set.go:250:6
// a specified capacity. Operations on the resulting set are not thread-safe.func NewThreadUnsafeSetWithSize[T comparable](cardinality int) Set[T] { return newThreadUnsafeSetWithSize[T](cardinality)250:6exported-declaration-comment
set.go:250:6
// a specified capacity. Operations on the resulting set are not thread-safe.func NewThreadUnsafeSetWithSize[T comparable](cardinality int) Set[T] { return newThreadUnsafeSetWithSize[T](cardinality)256:6constructor-interface-return
set.go:256:6
// Operations on the resulting set are thread-safe.func NewSetFromMapKeys[T comparable, V any](val map[T]V) Set[T] { s := newThreadSafeSetWithSize[T](len(val))256:6exported-declaration-comment
set.go:256:6
// Operations on the resulting set are thread-safe.func NewSetFromMapKeys[T comparable, V any](val map[T]V) Set[T] { s := newThreadSafeSetWithSize[T](len(val))268:6constructor-interface-return
set.go:268:6
// Operations on the resulting set are not thread-safe.func NewThreadUnsafeSetFromMapKeys[T comparable, V any](val map[T]V) Set[T] { s := newThreadUnsafeSetWithSize[T](len(val))268:6exported-declaration-comment
set.go:268:6
// Operations on the resulting set are not thread-safe.func NewThreadUnsafeSetFromMapKeys[T comparable, V any](val map[T]V) Set[T] { s := newThreadUnsafeSetWithSize[T](len(val))280:6exported-declaration-comment
set.go:280:6
// with Go 1.23, users can use a for loop to iterate over it.func Elements[T comparable](s Set[T]) func(func(element T) bool) { return func(yield func(element T) bool) {set123_test.go4
1:1format
set123_test.go:1:1
//go:build go1.23// +build go1.23- Fix (safe): run `strider fmt set123_test.go`
2:1redundant-build-tag
set123_test.go:2:1
//go:build go1.23// +build go1.234:9package-directory-mismatch
set123_test.go:4:9
package mapset10:6test-parallelism
set123_test.go:10:6
func Test_Elements123(t *testing.T) { a := NewSet[string]()set_test.go153
1:1file-length-limit
set_test.go:1:1
/*Open Source Initiative OSI - The MIT License (MIT):Licensing1:1format
set_test.go:1:1
/*Open Source Initiative OSI - The MIT License (MIT):Licensing- Fix (safe): run `strider fmt set_test.go`
26:9package-directory-mismatch
set_test.go:26:9
package mapset62:12error-strings
set_test.go:62:12
if !a.Equal(b) { t.Errorf("%v != %v\n", a, b) }66:6test-parallelism
set_test.go:66:6
func Test_NewSet(t *testing.T) { a := NewSet[int]()76:30add-constant
set_test.go:76:30
assertEqual(NewSet([]string{"a"}...), NewSet("a"), t) assertEqual(NewSet([]string{"a", "b"}...), NewSet("a", "b"), t)}79:6test-parallelism
set_test.go:79:6
func Test_NewUnsafeSet(t *testing.T) { a := NewThreadUnsafeSet[int]()87:6test-parallelism
set_test.go:87:6
func Test_AddSet(t *testing.T) { a := makeSetInt([]int{1, 2, 3})95:6test-parallelism
set_test.go:95:6
func Test_AddUnsafeSet(t *testing.T) { a := makeUnsafeSetInt([]int{1, 2, 3})103:6test-parallelism
set_test.go:103:6
func Test_AppendSet(t *testing.T) { a := makeSetIntWithAppend(1, 2, 3)111:6test-parallelism
set_test.go:111:6
func Test_AppendUnsafeSet(t *testing.T) { a := makeUnsafeSetIntWithAppend(1, 2, 3)119:6test-parallelism
set_test.go:119:6
func Test_AddSetNoDuplicate(t *testing.T) { a := makeSetInt([]int{7, 5, 3, 7})126:7optimize-operands-order
set_test.go:126:7
if !(a.Contains(7) && a.Contains(5) && a.Contains(3)) { t.Error("AddSetNoDuplicate set should have a 7, 5, and 3 in it.")131:6test-parallelism
set_test.go:131:6
func Test_AddUnsafeSetNoDuplicate(t *testing.T) { a := makeUnsafeSetInt([]int{7, 5, 3, 7})138:7optimize-operands-order
set_test.go:138:7
if !(a.Contains(7) && a.Contains(5) && a.Contains(3)) { t.Error("AddSetNoDuplicate set should have a 7, 5, and 3 in it.")143:6test-parallelism
set_test.go:143:6
func Test_AppendSetNoDuplicate(t *testing.T) { a := makeSetIntWithAppend(7, 5, 3, 7)150:7optimize-operands-order
set_test.go:150:7
if !(a.Contains(7) && a.Contains(5) && a.Contains(3)) { t.Error("AppendSetNoDuplicate set should have a 7, 5, and 3 in it.")155:6test-parallelism
set_test.go:155:6
func Test_AppendUnsafeSetNoDuplicate(t *testing.T) { a := makeUnsafeSetIntWithAppend(7, 5, 3, 7)162:7optimize-operands-order
set_test.go:162:7
if !(a.Contains(7) && a.Contains(5) && a.Contains(3)) { t.Error("AppendSetNoDuplicate set should have a 7, 5, and 3 in it.")167:6test-parallelism
set_test.go:167:6
func Test_AppendFrom(t *testing.T) { a := NewSet("Z", "Y", "X", "W")171:31add-constant
set_test.go:171:31
if !a.Equal(NewSet("Z", "Y", "X", "W", "A", "B")) { t.Error("Added set is not correct")171:36add-constant
set_test.go:171:36
if !a.Equal(NewSet("Z", "Y", "X", "W", "A", "B")) { t.Error("Added set is not correct")175:12error-strings
set_test.go:175:12
if num != 2 { t.Errorf("Number of added elements is not correct. num: %d", num) }179:6test-parallelism
set_test.go:179:6
func Test_UnsafeAppendFrom(t *testing.T) { a := NewThreadUnsafeSet("Z", "Y", "X", "W")180:26add-constant
set_test.go:180:26
func Test_UnsafeAppendFrom(t *testing.T) { a := NewThreadUnsafeSet("Z", "Y", "X", "W") num := a.AppendFrom(NewThreadUnsafeSet("A", "B", "X", "W"))180:31add-constant
set_test.go:180:31
func Test_UnsafeAppendFrom(t *testing.T) { a := NewThreadUnsafeSet("Z", "Y", "X", "W") num := a.AppendFrom(NewThreadUnsafeSet("A", "B", "X", "W"))181:41add-constant
set_test.go:181:41
a := NewThreadUnsafeSet("Z", "Y", "X", "W") num := a.AppendFrom(NewThreadUnsafeSet("A", "B", "X", "W"))181:46add-constant
set_test.go:181:46
a := NewThreadUnsafeSet("Z", "Y", "X", "W") num := a.AppendFrom(NewThreadUnsafeSet("A", "B", "X", "W"))187:12error-strings
set_test.go:187:12
if num != 2 { t.Errorf("Number of added elements is not correct. num: %d", num) }191:6test-parallelism
set_test.go:191:6
func Test_RemoveSet(t *testing.T) { a := makeSetInt([]int{6, 3, 1})212:6test-parallelism
set_test.go:212:6
func Test_RemoveAllSet(t *testing.T) { a := makeSetInt([]int{6, 3, 1, 8, 9})232:6test-parallelism
set_test.go:232:6
func Test_RemoveUnsafeSet(t *testing.T) { a := makeUnsafeSetInt([]int{6, 3, 1})249:11add-constant
set_test.go:249:11
if a.Cardinality() != 0 { t.Error("RemoveSet should be an empty set after removing 6 and 1") }253:6test-parallelism
set_test.go:253:6
func Test_RemoveAllUnsafeSet(t *testing.T) { a := makeUnsafeSetInt([]int{6, 3, 1, 8, 9})273:6test-parallelism
set_test.go:273:6
func Test_ContainsSet(t *testing.T) { a := NewSet[int]()292:7optimize-operands-order
set_test.go:292:7
if !(a.Contains(13) && a.Contains(7) && a.Contains(1)) { t.Error("ContainsSet should contain 13, 7, 1")297:6test-parallelism
set_test.go:297:6
func Test_ContainsUnsafeSet(t *testing.T) { a := NewThreadUnsafeSet[int]()316:7optimize-operands-order
set_test.go:316:7
if !(a.Contains(13) && a.Contains(7) && a.Contains(1)) { t.Error("ContainsSet should contain 13, 7, 1")321:6test-parallelism
set_test.go:321:6
func Test_ContainsMultipleSet(t *testing.T) { a := makeSetInt([]int{8, 6, 7, 5, 3, 0, 9})333:6test-parallelism
set_test.go:333:6
func Test_ContainsMultipleUnsafeSet(t *testing.T) { a := makeUnsafeSetInt([]int{8, 6, 7, 5, 3, 0, 9})345:6test-parallelism
set_test.go:345:6
func Test_ContainsOneSet(t *testing.T) { a := NewSet[int]()351:11add-constant
set_test.go:351:11
if !a.ContainsOne(71) { t.Error("ContainsSet should contain 71") }357:11add-constant
set_test.go:357:11
if a.ContainsOne(71) { t.Error("ContainsSet should not contain 71") }364:7optimize-operands-order
set_test.go:364:7
if !(a.ContainsOne(13) && a.ContainsOne(7) && a.ContainsOne(1)) { t.Error("ContainsSet should contain 13, 7, 1")365:11add-constant
set_test.go:365:11
if !(a.ContainsOne(13) && a.ContainsOne(7) && a.ContainsOne(1)) { t.Error("ContainsSet should contain 13, 7, 1") }369:6test-parallelism
set_test.go:369:6
func Test_ContainsOneUnsafeSet(t *testing.T) { a := NewThreadUnsafeSet[int]()388:7optimize-operands-order
set_test.go:388:7
if !(a.ContainsOne(13) && a.ContainsOne(7) && a.ContainsOne(1)) { t.Error("ContainsSet should contain 13, 7, 1")393:6test-parallelism
set_test.go:393:6
func Test_ContainsAnySet(t *testing.T) { a := NewSet[int]()425:6test-parallelism
set_test.go:425:6
func Test_ContainsAnyElement(t *testing.T) { a := NewSet[int]()452:6test-parallelism
set_test.go:452:6
}func Test_ClearSet(t *testing.T) { a := makeSetInt([]int{2, 5, 9, 10})462:6test-parallelism
set_test.go:462:6
func Test_ClearUnsafeSet(t *testing.T) { a := makeUnsafeSetInt([]int{2, 5, 9, 10})472:6test-parallelism
set_test.go:472:6
func Test_CardinalitySet(t *testing.T) { a := NewSet[int]()500:11add-constant
set_test.go:500:11
if a.Cardinality() != 0 { t.Error("set should have a size of 1") }504:6test-parallelism
set_test.go:504:6
func Test_CardinalityUnsafeSet(t *testing.T) { a := NewThreadUnsafeSet[int]()508:11add-constant
set_test.go:508:11
if a.Cardinality() != 0 { t.Error("set should be an empty set") }536:6test-parallelism
set_test.go:536:6
func Test_SetIsSubset(t *testing.T) { a := makeSetInt([]int{1, 2, 3, 5, 7})555:6test-parallelism
set_test.go:555:6
func Test_SetIsProperSubset(t *testing.T) { a := makeSetInt([]int{1, 2, 3, 5, 7})576:6test-parallelism
set_test.go:576:6
func Test_UnsafeSetIsSubset(t *testing.T) { a := makeUnsafeSetInt([]int{1, 2, 3, 5, 7})595:6test-parallelism
set_test.go:595:6
func Test_UnsafeSetIsProperSubset(t *testing.T) { a := makeUnsafeSetInt([]int{1, 2, 3, 5, 7})605:11add-constant
set_test.go:605:11
if !a.IsSubset(b) { t.Error("set a should be a subset of set b") }621:6test-parallelism
set_test.go:621:6
func Test_SetIsSuperset(t *testing.T) { a := NewSet[int]()645:6test-parallelism
set_test.go:645:6
func Test_SetIsProperSuperset(t *testing.T) { a := NewSet[int]()666:11add-constant
set_test.go:666:11
if !a.IsSuperset(b) { t.Error("set a should be a superset of set b") }682:6test-parallelism
set_test.go:682:6
func Test_UnsafeSetIsSuperset(t *testing.T) { a := NewThreadUnsafeSet[int]()706:6test-parallelism
set_test.go:706:6
func Test_UnsafeSetIsProperSuperset(t *testing.T) { a := NewThreadUnsafeSet[int]()736:11add-constant
set_test.go:736:11
if a.IsSuperset(b) { t.Error("set a should not be a superset of set b because set b has a 42") }743:6test-parallelism
set_test.go:743:6
func Test_SetUnion(t *testing.T) { a := NewSet[int]()779:6test-parallelism
set_test.go:779:6
func Test_UnsafeSetUnion(t *testing.T) { a := NewThreadUnsafeSet[int]()815:6test-parallelism
set_test.go:815:6
func Test_SetIntersect(t *testing.T) { a := NewSet[int]()837:7optimize-operands-order
set_test.go:837:7
if !(d.Cardinality() == 1 && d.Contains(10)) { t.Error("set d should have a size of 1 and contain the item 10")842:6test-parallelism
set_test.go:842:6
func Test_UnsafeSetIntersect(t *testing.T) { a := NewThreadUnsafeSet[int]()864:7optimize-operands-order
set_test.go:864:7
if !(d.Cardinality() == 1 && d.Contains(10)) { t.Error("set d should have a size of 1 and contain the item 10")869:6test-parallelism
set_test.go:869:6
func Test_SetDifference(t *testing.T) { a := NewSet[int]()885:7optimize-operands-order
set_test.go:885:7
if !(c.Cardinality() == 1 && c.Contains(2)) { t.Error("the difference of set a to b is the set of 1 item: 2")890:6test-parallelism
set_test.go:890:6
func Test_UnsafeSetDifference(t *testing.T) { a := NewThreadUnsafeSet[int]()906:7optimize-operands-order
set_test.go:906:7
if !(c.Cardinality() == 1 && c.Contains(2)) { t.Error("the difference of set a to b is the set of 1 item: 2")911:6test-parallelism
set_test.go:911:6
func Test_SetSymmetricDifference(t *testing.T) { a := NewSet[int]()928:7optimize-operands-order
set_test.go:928:7
if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) { t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")928:7optimize-operands-order
set_test.go:928:7
if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) { t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")928:7optimize-operands-order
set_test.go:928:7
if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) { t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")928:7optimize-operands-order
set_test.go:928:7
if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) { t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")928:7optimize-operands-order
set_test.go:928:7
if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) { t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")928:7optimize-operands-order
set_test.go:928:7
if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) { t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")933:6test-parallelism
set_test.go:933:6
func Test_UnsafeSetSymmetricDifference(t *testing.T) { a := NewThreadUnsafeSet[int]()950:7optimize-operands-order
set_test.go:950:7
if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) { t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")950:7optimize-operands-order
set_test.go:950:7
if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) { t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")950:7optimize-operands-order
set_test.go:950:7
if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) { t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")950:7optimize-operands-order
set_test.go:950:7
if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) { t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")950:7optimize-operands-order
set_test.go:950:7
if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) { t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")950:7optimize-operands-order
set_test.go:950:7
if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) { t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")955:6test-parallelism
set_test.go:955:6
func Test_SetEqual(t *testing.T) { a := NewSet[int]()992:6test-parallelism
set_test.go:992:6
func Test_UnsafeSetEqual(t *testing.T) { a := NewThreadUnsafeSet[int]()1029:6test-parallelism
set_test.go:1029:6
func Test_SetClone(t *testing.T) { a := NewSet[int]()1053:6test-parallelism
set_test.go:1053:6
func Test_UnsafeSetClone(t *testing.T) { a := NewThreadUnsafeSet[int]()1077:6test-parallelism
set_test.go:1077:6
func Test_Each(t *testing.T) { a := NewSet[string]()1108:6test-parallelism
set_test.go:1108:6
func Test_Filter(t *testing.T) { a := NewSet[string]()1122:12error-strings
set_test.go:1122:12
if !keepFromX.Equal(expected) { t.Errorf("Expected %v, got %v", expected, keepFromX) }1127:12error-strings
set_test.go:1127:12
if a.Cardinality() != 4 { t.Errorf("Expected source cardinality 4, got %d", a.Cardinality()) }1133:12error-strings
set_test.go:1133:12
if !all.Equal(a) { t.Errorf("Expected clone of source, got %v", all) }1142:12error-strings
set_test.go:1142:12
if none.Cardinality() != 0 { t.Errorf("Expected empty set, got %v", none) }1149:12error-strings
set_test.go:1149:12
if emptyOut.Cardinality() != 0 { t.Errorf("Expected empty set from empty source, got %v", emptyOut) }1153:6test-parallelism
set_test.go:1153:6
func Test_UnsafeFilter(t *testing.T) { a := NewThreadUnsafeSet[int]()1166:12error-strings
set_test.go:1166:12
if !evens.Equal(expected) { t.Errorf("Expected %v, got %v", expected, evens) }1171:12error-strings
set_test.go:1171:12
if a.Cardinality() != 4 { t.Errorf("Expected source cardinality 4, got %d", a.Cardinality()) }1177:12error-strings
set_test.go:1177:12
if none.Cardinality() != 0 { t.Errorf("Expected empty set, got %v", none) }1184:12error-strings
set_test.go:1184:12
if emptyOut.Cardinality() != 0 { t.Errorf("Expected empty set from empty source, got %v", emptyOut) }1188:6test-parallelism
set_test.go:1188:6
func Test_FilterVisitsAllElements(t *testing.T) { a := NewSet(1, 2, 3, 4, 5)1198:12error-strings
set_test.go:1198:12
if !visited.Equal(a) { t.Errorf("Filter did not visit every element: visited %v, expected %v", visited, a) }1202:6test-parallelism
set_test.go:1202:6
func Test_Iter(t *testing.T) { a := NewSet[string]()1220:6test-parallelism
set_test.go:1220:6
func Test_UnsafeIter(t *testing.T) { a := NewThreadUnsafeSet[string]()1238:6test-parallelism
set_test.go:1238:6
func Test_Iterator(t *testing.T) { a := NewSet[string]()1256:6test-parallelism
set_test.go:1256:6
func Test_UnsafeIterator(t *testing.T) { a := NewThreadUnsafeSet[string]()1274:6test-parallelism
set_test.go:1274:6
func Test_IteratorStop(t *testing.T) { a := NewSet[string]()1289:6test-parallelism
set_test.go:1289:6
func Test_PopSafe(t *testing.T) { a := NewSet[string]()1293:8add-constant
set_test.go:1293:8
a.Add("a") a.Add("b") a.Add("c")1299:3no-naked-return
set_test.go:1299:3
v, _ = a.Pop() return }1326:6test-parallelism
set_test.go:1326:6
func Test_PopUnsafe(t *testing.T) { a := NewThreadUnsafeSet[string]()1331:8add-constant
set_test.go:1331:8
a.Add("b") a.Add("c") a.Add("d")1332:8add-constant
set_test.go:1332:8
a.Add("c") a.Add("d")1336:3no-naked-return
set_test.go:1336:3
v, _ = a.Pop() return }1363:6cognitive-complexity
set_test.go:1363:6
func Test_PopNSafe(t *testing.T) { a := NewSet[string]()1363:6cyclomatic-complexity
set_test.go:1363:6
func Test_PopNSafe(t *testing.T) { a := NewSet[string]()1363:6test-parallelism
set_test.go:1363:6
func Test_PopNSafe(t *testing.T) { a := NewSet[string]()1371:2overwritten-before-use
set_test.go:1371:2
// Test pop with n <= 0 items, count := a.PopN(0) if count != 0 {1375:2overwritten-before-use
set_test.go:1375:2
} items, count = a.PopN(-1) if count != 0 {1408:12add-constant
set_test.go:1408:12
if count != 0 { t.Errorf("expected 0 items popped, got %d", count) }1415:11add-constant
set_test.go:1415:11
if !captureSet.Contains("c", "a", "d", "b") { t.Error("unexpected result set; should be a,b,c,d (any order is fine") }1419:6cognitive-complexity
set_test.go:1419:6
func Test_PopNUnsafe(t *testing.T) { a := NewThreadUnsafeSet[string]()1419:6cyclomatic-complexity
set_test.go:1419:6
func Test_PopNUnsafe(t *testing.T) { a := NewThreadUnsafeSet[string]()1419:6test-parallelism
set_test.go:1419:6
func Test_PopNUnsafe(t *testing.T) { a := NewThreadUnsafeSet[string]()1427:2overwritten-before-use
set_test.go:1427:2
// Test pop with n <= 0 items, count := a.PopN(0) if count != 0 {1431:2overwritten-before-use
set_test.go:1431:2
} items, count = a.PopN(-1) if count != 0 {1441:12add-constant
set_test.go:1441:12
if count != 2 { t.Errorf("expected 2 items popped, got %d", count) }1475:6test-parallelism
set_test.go:1475:6
func Test_EmptySetProperties(t *testing.T) { empty := NewSet[string]()1516:6test-parallelism
set_test.go:1516:6
func Test_ToSliceUnthreadsafe(t *testing.T) { s := makeUnsafeSetInt([]int{1, 2, 3})1520:12error-strings
set_test.go:1520:12
if len(setAsSlice) != s.Cardinality() { t.Errorf("Set length is incorrect: %v", len(setAsSlice)) }1525:13error-strings
set_test.go:1525:13
if !s.Contains(i) { t.Errorf("Set is missing element: %v", i) }1530:6test-parallelism
set_test.go:1530:6
func Test_NewSetFromMapKey_Ints(t *testing.T) { m := map[int]int{1539:12error-strings
set_test.go:1539:12
if len(m) != s.Cardinality() { t.Errorf("Length of Set is not the same as the map. Expected: %d. Actual: %d", len(m), s.Cardinality()) }1544:13error-strings
set_test.go:1544:13
if !s.Contains(k) { t.Errorf("Element %d not found in map: %v", k, m) }1549:6test-parallelism
set_test.go:1549:6
func Test_NewSetFromMapKey_Strings(t *testing.T) { m := map[int]int{1558:12error-strings
set_test.go:1558:12
if len(m) != s.Cardinality() { t.Errorf("Length of Set is not the same as the map. Expected: %d. Actual: %d", len(m), s.Cardinality()) }1563:13error-strings
set_test.go:1563:13
if !s.Contains(k) { t.Errorf("Element %q not found in map: %v", k, m) }1568:6test-parallelism
set_test.go:1568:6
func Test_NewThreadUnsafeSetFromMapKey_Ints(t *testing.T) { m := map[int]int{1577:12add-constant
set_test.go:1577:12
if len(m) != s.Cardinality() { t.Errorf("Length of Set is not the same as the map. Expected: %d. Actual: %d", len(m), s.Cardinality()) }1577:12error-strings
set_test.go:1577:12
if len(m) != s.Cardinality() { t.Errorf("Length of Set is not the same as the map. Expected: %d. Actual: %d", len(m), s.Cardinality()) }1582:13error-strings
set_test.go:1582:13
if !s.Contains(k) { t.Errorf("Element %d not found in map: %v", k, m) }1587:6test-parallelism
set_test.go:1587:6
func Test_NewThreadUnsafeSetFromMapKey_Strings(t *testing.T) { m := map[int]int{1596:12error-strings
set_test.go:1596:12
if len(m) != s.Cardinality() { t.Errorf("Length of Set is not the same as the map. Expected: %d. Actual: %d", len(m), s.Cardinality()) }1601:13error-strings
set_test.go:1601:13
if !s.Contains(k) { t.Errorf("Element %q not found in map: %v", k, m) }1606:6test-parallelism
set_test.go:1606:6
func Test_Elements(t *testing.T) { a := NewSet[string]()1638:6test-parallelism
set_test.go:1638:6
func Test_Example(t *testing.T) { /*1638:19unused-parameter
set_test.go:1638:19
func Test_Example(t *testing.T) { /*sorted.go4
2:1redundant-build-tag
sorted.go:2:1
//go:build go1.21// +build go1.2129:9package-comments
sorted.go:29:9
package mapset29:9package-directory-mismatch
sorted.go:29:9
package mapset38:6exported-declaration-comment
sorted.go:38:6
// When sorting floating-point numbers, NaNs are ordered before other values.func Sorted[E cmp.Ordered](set Set[E]) []E { s := set.ToSlice()sorted_test.go10
1:1format
sorted_test.go:1:1
//go:build go1.21// +build go1.21- Fix (safe): run `strider fmt sorted_test.go`
2:1redundant-build-tag
sorted_test.go:2:1
//go:build go1.21// +build go1.2129:9package-directory-mismatch
sorted_test.go:29:9
package mapset35:6test-parallelism
sorted_test.go:35:6
func Test_Sorted(t *testing.T) { test := func(t *testing.T, ctor func(vals ...string) Set[string]) {41:13error-strings
sorted_test.go:41:13
if len(sorted) != set.Cardinality() { t.Errorf("Length of slice is not the same as the set. Expected: %d. Actual: %d", set.Cardinality(), len(sorted)) }45:13error-strings
sorted_test.go:45:13
if sorted[0] != "apple" { t.Errorf("Element 0 was not equal to apple: %s", sorted[0]) }48:13error-strings
sorted_test.go:48:13
if sorted[1] != "banana" { t.Errorf("Element 1 was not equal to banana: %s", sorted[1]) }51:13error-strings
sorted_test.go:51:13
if sorted[2] != "pear" { t.Errorf("Element 2 was not equal to pear: %s", sorted[2]) }55:16test-parallelism
sorted_test.go:55:16
t.Run("Safe", func(t *testing.T) { test(t, NewSet[string])58:18test-parallelism
sorted_test.go:58:18
}) t.Run("Unsafe", func(t *testing.T) { test(t, NewThreadUnsafeSet[string])threadsafe.go50
1:1format
threadsafe.go:1:1
/*Open Source Initiative OSI - The MIT License (MIT):Licensing- Fix (safe): run `strider fmt threadsafe.go`
26:9package-comments
threadsafe.go:26:9
package mapset26:9package-directory-mismatch
threadsafe.go:26:9
package mapset51:28exported-declaration-comment
threadsafe.go:51:28
func (t *threadSafeSet[T]) Add(v T) bool { t.Lock()58:28exported-declaration-comment
threadsafe.go:58:28
func (t *threadSafeSet[T]) Append(v ...T) int { t.Lock()65:28exported-declaration-comment
threadsafe.go:65:28
func (t *threadSafeSet[T]) AppendFrom(other Set[T]) int { o := other.(*threadSafeSet[T])66:12unchecked-type-assertion
threadsafe.go:66:12
func (t *threadSafeSet[T]) AppendFrom(other Set[T]) int { o := other.(*threadSafeSet[T])76:28exported-declaration-comment
threadsafe.go:76:28
func (t *threadSafeSet[T]) Contains(v ...T) bool { t.RLock()84:28exported-declaration-comment
threadsafe.go:84:28
func (t *threadSafeSet[T]) ContainsOne(v T) bool { t.RLock()92:28exported-declaration-comment
threadsafe.go:92:28
func (t *threadSafeSet[T]) ContainsAny(v ...T) bool { t.RLock()100:28exported-declaration-comment
threadsafe.go:100:28
func (t *threadSafeSet[T]) ContainsAnyElement(other Set[T]) bool { o := other.(*threadSafeSet[T])101:12unchecked-type-assertion
threadsafe.go:101:12
func (t *threadSafeSet[T]) ContainsAnyElement(other Set[T]) bool { o := other.(*threadSafeSet[T])113:28exported-declaration-comment
threadsafe.go:113:28
func (t *threadSafeSet[T]) IsEmpty() bool { return t.Cardinality() == 0117:28exported-declaration-comment
threadsafe.go:117:28
func (t *threadSafeSet[T]) IsSubset(other Set[T]) bool { o := other.(*threadSafeSet[T])118:12unchecked-type-assertion
threadsafe.go:118:12
func (t *threadSafeSet[T]) IsSubset(other Set[T]) bool { o := other.(*threadSafeSet[T])129:28exported-declaration-comment
threadsafe.go:129:28
func (t *threadSafeSet[T]) IsProperSubset(other Set[T]) bool { o := other.(*threadSafeSet[T])130:12unchecked-type-assertion
threadsafe.go:130:12
func (t *threadSafeSet[T]) IsProperSubset(other Set[T]) bool { o := other.(*threadSafeSet[T])140:28exported-declaration-comment
threadsafe.go:140:28
func (t *threadSafeSet[T]) IsSuperset(other Set[T]) bool { return other.IsSubset(t)144:28exported-declaration-comment
threadsafe.go:144:28
func (t *threadSafeSet[T]) IsProperSuperset(other Set[T]) bool { return other.IsProperSubset(t)148:28exported-declaration-comment
threadsafe.go:148:28
func (t *threadSafeSet[T]) Union(other Set[T]) Set[T] { o := other.(*threadSafeSet[T])149:12unchecked-type-assertion
threadsafe.go:149:12
func (t *threadSafeSet[T]) Union(other Set[T]) Set[T] { o := other.(*threadSafeSet[T])154:35unchecked-type-assertion
threadsafe.go:154:35
unsafeUnion := t.uss.Union(o.uss).(*threadUnsafeSet[T]) ret := &threadSafeSet[T]{uss: unsafeUnion}161:28exported-declaration-comment
threadsafe.go:161:28
func (t *threadSafeSet[T]) Intersect(other Set[T]) Set[T] { o := other.(*threadSafeSet[T])162:12unchecked-type-assertion
threadsafe.go:162:12
func (t *threadSafeSet[T]) Intersect(other Set[T]) Set[T] { o := other.(*threadSafeSet[T])167:46unchecked-type-assertion
threadsafe.go:167:46
unsafeIntersection := t.uss.Intersect(o.uss).(*threadUnsafeSet[T]) ret := &threadSafeSet[T]{uss: unsafeIntersection}174:28exported-declaration-comment
threadsafe.go:174:28
func (t *threadSafeSet[T]) Difference(other Set[T]) Set[T] { o := other.(*threadSafeSet[T])175:12unchecked-type-assertion
threadsafe.go:175:12
func (t *threadSafeSet[T]) Difference(other Set[T]) Set[T] { o := other.(*threadSafeSet[T])180:45unchecked-type-assertion
threadsafe.go:180:45
unsafeDifference := t.uss.Difference(o.uss).(*threadUnsafeSet[T]) ret := &threadSafeSet[T]{uss: unsafeDifference}187:28exported-declaration-comment
threadsafe.go:187:28
func (t *threadSafeSet[T]) SymmetricDifference(other Set[T]) Set[T] { o := other.(*threadSafeSet[T])188:12unchecked-type-assertion
threadsafe.go:188:12
func (t *threadSafeSet[T]) SymmetricDifference(other Set[T]) Set[T] { o := other.(*threadSafeSet[T])193:54unchecked-type-assertion
threadsafe.go:193:54
unsafeDifference := t.uss.SymmetricDifference(o.uss).(*threadUnsafeSet[T]) ret := &threadSafeSet[T]{uss: unsafeDifference}200:28exported-declaration-comment
threadsafe.go:200:28
func (t *threadSafeSet[T]) Clear() { t.Lock()206:28exported-declaration-comment
threadsafe.go:206:28
func (t *threadSafeSet[T]) Remove(v T) { t.Lock()212:28exported-declaration-comment
threadsafe.go:212:28
func (t *threadSafeSet[T]) RemoveAll(i ...T) { t.Lock()218:28exported-declaration-comment
threadsafe.go:218:28
func (t *threadSafeSet[T]) Cardinality() int { t.RLock()224:28exported-declaration-comment
threadsafe.go:224:28
func (t *threadSafeSet[T]) Each(cb func(T) bool) { t.RLock()234:28exported-declaration-comment
threadsafe.go:234:28
func (t *threadSafeSet[T]) Filter(cb func(T) bool) Set[T] { t.RLock()246:28exported-declaration-comment
threadsafe.go:246:28
func (t *threadSafeSet[T]) Iter() <-chan T { ch := make(chan T)261:28exported-declaration-comment
threadsafe.go:261:28
func (t *threadSafeSet[T]) Iterator() *Iterator[T] { iterator, ch, stopCh := newIterator[T]()281:28exported-declaration-comment
threadsafe.go:281:28
func (t *threadSafeSet[T]) Equal(other Set[T]) bool { o := other.(*threadSafeSet[T])282:12unchecked-type-assertion
threadsafe.go:282:12
func (t *threadSafeSet[T]) Equal(other Set[T]) bool { o := other.(*threadSafeSet[T])293:28exported-declaration-comment
threadsafe.go:293:28
func (t *threadSafeSet[T]) Clone() Set[T] { t.RLock()296:30unchecked-type-assertion
threadsafe.go:296:30
unsafeClone := t.uss.Clone().(*threadUnsafeSet[T]) ret := &threadSafeSet[T]{uss: unsafeClone}309:28exported-declaration-comment
threadsafe.go:309:28
func (t *threadSafeSet[T]) Pop() (T, bool) { t.Lock()315:28exported-declaration-comment
threadsafe.go:315:28
func (t *threadSafeSet[T]) PopN(n int) ([]T, int) { t.Lock()321:28exported-declaration-comment
threadsafe.go:321:28
func (t *threadSafeSet[T]) ToSlice() []T { t.RLock()332:28exported-declaration-comment
threadsafe.go:332:28
func (t *threadSafeSet[T]) MarshalJSON() ([]byte, error) { t.RLock()340:28exported-declaration-comment
threadsafe.go:340:28
func (t *threadSafeSet[T]) UnmarshalJSON(p []byte) error { t.Lock()348:28exported-declaration-comment
threadsafe.go:348:28
func (t *threadSafeSet[T]) MarshalBSONValue() (bsontype.Type, []byte, error) { t.RLock()356:28exported-declaration-comment
threadsafe.go:356:28
func (t *threadSafeSet[T]) UnmarshalBSONValue(bt bsontype.Type, p []byte) error { t.Lock()threadsafe_test.go101
1:1file-length-limit
threadsafe_test.go:1:1
/*Open Source Initiative OSI - The MIT License (MIT):Licensing1:1format
threadsafe_test.go:1:1
/*Open Source Initiative OSI - The MIT License (MIT):Licensing- Fix (safe): run `strider fmt threadsafe_test.go`
26:9package-directory-mismatch
threadsafe_test.go:26:9
package mapset40:7exported-declaration-comment
threadsafe_test.go:40:7
const N = 100042:6test-parallelism
threadsafe_test.go:42:6
func Test_AddConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)60:13error-strings
threadsafe_test.go:60:13
if !s.Contains(i) { t.Errorf("Set is missing element: %v", i) }65:6test-parallelism
threadsafe_test.go:65:6
func Test_AppendConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)84:13error-strings
threadsafe_test.go:84:13
if !s.Contains(i) { t.Errorf("Set is missing element: %v", i) }89:6test-parallelism
threadsafe_test.go:89:6
func Test_CardinalityConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)101:14error-strings
threadsafe_test.go:101:14
if newElems < elems { t.Errorf("Cardinality shrunk from %v to %v", elems, newElems) }113:6test-parallelism
threadsafe_test.go:113:6
func Test_ClearConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)113:27unused-parameter
threadsafe_test.go:113:27
func Test_ClearConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)134:6test-parallelism
threadsafe_test.go:134:6
func Test_CloneConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)134:27unused-parameter
threadsafe_test.go:134:27
func Test_CloneConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)156:6test-parallelism
threadsafe_test.go:156:6
func Test_ContainsConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)156:30unused-parameter
threadsafe_test.go:156:30
func Test_ContainsConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)161:2slice-preallocation
threadsafe_test.go:161:2
ints := rand.Perm(N) integers := make([]int, 0) for _, v := range ints {178:6test-parallelism
threadsafe_test.go:178:6
func Test_ContainsOneConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)178:33unused-parameter
threadsafe_test.go:178:33
func Test_ContainsOneConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)199:6test-parallelism
threadsafe_test.go:199:6
func Test_ContainsAnyConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)199:33unused-parameter
threadsafe_test.go:199:33
func Test_ContainsAnyConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)204:2slice-preallocation
threadsafe_test.go:204:2
ints := rand.Perm(N) integers := make([]int, 0) for _, v := range ints {223:6test-parallelism
threadsafe_test.go:223:6
func Test_ContainsAnyElementConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)223:40unused-parameter
threadsafe_test.go:223:40
func Test_ContainsAnyElementConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)244:6test-parallelism
threadsafe_test.go:244:6
func Test_DifferenceConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)244:32unused-parameter
threadsafe_test.go:244:32
func Test_DifferenceConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)265:6test-parallelism
threadsafe_test.go:265:6
func Test_EqualConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)265:27unused-parameter
threadsafe_test.go:265:27
func Test_EqualConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)286:6test-parallelism
threadsafe_test.go:286:6
func Test_IntersectConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)286:31unused-parameter
threadsafe_test.go:286:31
func Test_IntersectConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)307:6test-parallelism
threadsafe_test.go:307:6
func Test_IsEmptyConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)317:7optimize-operands-order
threadsafe_test.go:317:7
size := s.Cardinality() if s.IsEmpty() && size > 0 { t.Errorf("Is Empty should be return false")318:14error-strings
threadsafe_test.go:318:14
if s.IsEmpty() && size > 0 { t.Errorf("Is Empty should be return false") }330:6test-parallelism
threadsafe_test.go:330:6
func Test_IsSubsetConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)330:30unused-parameter
threadsafe_test.go:330:30
func Test_IsSubsetConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)351:6test-parallelism
threadsafe_test.go:351:6
func Test_IsProperSubsetConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)351:36unused-parameter
threadsafe_test.go:351:36
func Test_IsProperSubsetConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)372:6test-parallelism
threadsafe_test.go:372:6
func Test_IsSupersetConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)372:32unused-parameter
threadsafe_test.go:372:32
func Test_IsSupersetConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)393:6test-parallelism
threadsafe_test.go:393:6
func Test_IsProperSupersetConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)393:38unused-parameter
threadsafe_test.go:393:38
func Test_IsProperSupersetConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)414:6test-parallelism
threadsafe_test.go:414:6
func Test_EachConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)443:6test-parallelism
threadsafe_test.go:443:6
func Test_FilterConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)466:15error-strings
threadsafe_test.go:466:15
if elem%2 != 0 { t.Errorf("Filter produced odd element %d", elem) }469:15error-strings
threadsafe_test.go:469:15
if !s.Contains(elem) { t.Errorf("Filter produced element %d not in source", elem) }482:6cognitive-complexity
threadsafe_test.go:482:6
func Test_IterConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)482:6test-parallelism
threadsafe_test.go:482:6
func Test_IterConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)482:26unused-parameter
threadsafe_test.go:482:26
func Test_IterConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)491:2slice-preallocation
threadsafe_test.go:491:2
cs := make([]<-chan int, 0) for range ints {496:17use-any
threadsafe_test.go:496:17
c := make(chan interface{}) go func() {515:6test-parallelism
threadsafe_test.go:515:6
func Test_RemoveConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)535:12error-strings
threadsafe_test.go:535:12
if s.Cardinality() != 0 { t.Errorf("Expected cardinality 0; got %v", s.Cardinality()) }539:6test-parallelism
threadsafe_test.go:539:6
func Test_StringConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)539:28unused-parameter
threadsafe_test.go:539:28
func Test_StringConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)559:6test-parallelism
threadsafe_test.go:559:6
func Test_SymmetricDifferenceConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)559:41unused-parameter
threadsafe_test.go:559:41
func Test_SymmetricDifferenceConcurrent(t *testing.T) { runtime.GOMAXPROCS(2)580:6test-parallelism
threadsafe_test.go:580:6
func Test_ToSlice(t *testing.T) { runtime.GOMAXPROCS(2)598:12error-strings
threadsafe_test.go:598:12
if len(setAsSlice) != s.Cardinality() { t.Errorf("Set length is incorrect: %v", len(setAsSlice)) }603:13add-constant
threadsafe_test.go:603:13
if !s.Contains(i) { t.Errorf("Set is missing element: %v", i) }603:13error-strings
threadsafe_test.go:603:13
if !s.Contains(i) { t.Errorf("Set is missing element: %v", i) }610:6test-parallelism
threadsafe_test.go:610:6
// This code reveals the deadlock however it doesn't happen consistently.func Test_ToSliceDeadlock(t *testing.T) { runtime.GOMAXPROCS(2)610:27unused-parameter
threadsafe_test.go:610:27
// This code reveals the deadlock however it doesn't happen consistently.func Test_ToSliceDeadlock(t *testing.T) { runtime.GOMAXPROCS(2)629:6test-parallelism
threadsafe_test.go:629:6
func Test_UnmarshalJSON(t *testing.T) { s := []byte(`["test", "1", "2", "3"]`) //,["4,5,6"]]`)633:11redundant-conversion
threadsafe_test.go:633:11
[]string{ string(json.Number("1")), string(json.Number("2")),634:11redundant-conversion
threadsafe_test.go:634:11
string(json.Number("1")), string(json.Number("2")), string(json.Number("3")),635:11redundant-conversion
threadsafe_test.go:635:11
string(json.Number("2")), string(json.Number("3")), "test",643:12error-strings
threadsafe_test.go:643:12
if err != nil { t.Errorf("Error should be nil: %v", err) }647:12error-strings
threadsafe_test.go:647:12
if !expected.Equal(actual) { t.Errorf("Expected no difference, got: %v", expected.Difference(actual)) }651:6test-parallelism
threadsafe_test.go:651:6
func Test_MarshalJSON(t *testing.T) { expected := NewSet(654:11redundant-conversion
threadsafe_test.go:654:11
[]string{ string(json.Number("1")), "test",662:5add-constant
threadsafe_test.go:662:5
[]string{ "1", "test",663:5add-constant
threadsafe_test.go:663:5
"1", "test", }...,668:12error-strings
threadsafe_test.go:668:12
if err != nil { t.Errorf("Error should be nil: %v", err) }674:12add-constant
threadsafe_test.go:674:12
if err != nil { t.Errorf("Error should be nil: %v", err) }674:12error-strings
threadsafe_test.go:674:12
if err != nil { t.Errorf("Error should be nil: %v", err) }678:12error-strings
threadsafe_test.go:678:12
if !expected.Equal(actual) { t.Errorf("Expected no difference, got: %v", expected.Difference(actual)) }685:6test-parallelism
threadsafe_test.go:685:6
// that was called out on issue: https://github.com/deckarep/golang-set/issues/163.func Test_DeadlockOnEachCallbackWhenPanic(t *testing.T) { numbers := []int{1, 2, 3, 4}711:12error-strings
threadsafe_test.go:711:12
if widgets.Cardinality() != 4 { t.Errorf("Expected widgets to have 4 elements, but has %d", card) }714:2discarded-error-result
threadsafe_test.go:714:2
doWork(widgets)724:12error-strings
threadsafe_test.go:724:12
if widgets.Cardinality() != 5 { t.Errorf("Expected widgets to have 5 elements, but has %d", card) }728:6test-parallelism
threadsafe_test.go:728:6
func Test_UnmarshalBSONValue(t *testing.T) { tp, s, initErr := bson.MarshalValue(734:12error-strings
threadsafe_test.go:734:12
if initErr != nil { t.Errorf("Init Error should be nil: %v", initErr)740:12error-strings
threadsafe_test.go:740:12
if tp != bson.TypeArray { t.Errorf("Encoded Type should be bson.Array, got: %v", tp)745:26add-constant
threadsafe_test.go:745:26
expected := NewSet("1", "2", "3", "test") actual := NewSet[string]()745:31add-constant
threadsafe_test.go:745:31
expected := NewSet("1", "2", "3", "test") actual := NewSet[string]()749:12error-strings
threadsafe_test.go:749:12
if err != nil { t.Errorf("Error should be nil: %v", err) }753:12add-constant
threadsafe_test.go:753:12
if !expected.Equal(actual) { t.Errorf("Expected no difference, got: %v", expected.Difference(actual)) }753:12error-strings
threadsafe_test.go:753:12
if !expected.Equal(actual) { t.Errorf("Expected no difference, got: %v", expected.Difference(actual)) }757:6test-parallelism
threadsafe_test.go:757:6
func TestThreadUnsafeSet_UnmarshalBSONValue(t *testing.T) { tp, s, initErr := bson.MarshalValue(759:10redundant-conversion
threadsafe_test.go:759:10
tp, s, initErr := bson.MarshalValue( bson.A{int64(1), int64(2), int64(3)}, )759:20redundant-conversion
threadsafe_test.go:759:20
tp, s, initErr := bson.MarshalValue( bson.A{int64(1), int64(2), int64(3)}, )759:30redundant-conversion
threadsafe_test.go:759:30
tp, s, initErr := bson.MarshalValue( bson.A{int64(1), int64(2), int64(3)}, )763:12error-strings
threadsafe_test.go:763:12
if initErr != nil { t.Errorf("Init Error should be nil: %v", initErr)769:12error-strings
threadsafe_test.go:769:12
if tp != bson.TypeArray { t.Errorf("Encoded Type should be bson.Array, got: %v", tp)776:51redundant-conversion
threadsafe_test.go:776:51
actual := NewThreadUnsafeSet[int64]() err := actual.UnmarshalBSONValue(bson.TypeArray, []byte(s)) if err != nil {778:12error-strings
threadsafe_test.go:778:12
if err != nil { t.Errorf("Error should be nil: %v", err) }781:12error-strings
threadsafe_test.go:781:12
if !expected.Equal(actual) { t.Errorf("Expected no difference, got: %v", expected.Difference(actual)) }785:6test-parallelism
threadsafe_test.go:785:6
func Test_MarshalBSONValue(t *testing.T) { expected := NewSet("1", "test")792:12error-strings
threadsafe_test.go:792:12
if err != nil { t.Errorf("Error should be nil: %v", err) }798:12error-strings
threadsafe_test.go:798:12
if err != nil { t.Errorf("Error should be nil: %v", err) }802:12error-strings
threadsafe_test.go:802:12
if !expected.Equal(actual) { t.Errorf("Expected no difference, got: %v", expected.Difference(actual)) }threadunsafe.go58
1:1format
threadunsafe.go:1:1
/*Open Source Initiative OSI - The MIT License (MIT):Licensing- Fix (safe): run `strider fmt threadunsafe.go`
26:9package-comments
threadunsafe.go:26:9
package mapset26:9package-directory-mismatch
threadunsafe.go:26:9
package mapset37:42nested-structs
threadunsafe.go:37:42
type threadUnsafeSet[T comparable] map[T]struct{}40:1top-level-declaration-order
threadunsafe.go:40:1
// Assert concrete type:threadUnsafeSet adheres to Set interface.var _ Set[string] = (*threadUnsafeSet[string])(nil)52:30exported-declaration-comment
threadunsafe.go:52:30
func (s *threadUnsafeSet[T]) Add(v T) bool { prevLen := s.Cardinality()59:30confusing-naming
threadunsafe.go:59:30
// private version of Add which doesn't return a valuefunc (s *threadUnsafeSet[T]) add(v T) { (*s)[v] = struct{}{}60:12nested-structs
threadunsafe.go:60:12
func (s *threadUnsafeSet[T]) add(v T) { (*s)[v] = struct{}{}}63:30exported-declaration-comment
threadunsafe.go:63:30
func (s *threadUnsafeSet[T]) Append(vs ...T) int { prevLen := s.Cardinality()70:30confusing-naming
threadunsafe.go:70:30
// private version of Append which doesn't return a valuefunc (s *threadUnsafeSet[T]) append(vs ...T) { for i := range vs {76:30exported-declaration-comment
threadunsafe.go:76:30
func (s *threadUnsafeSet[T]) AppendFrom(other Set[T]) int { o := other.(*threadUnsafeSet[T])77:12unchecked-type-assertion
threadunsafe.go:77:12
func (s *threadUnsafeSet[T]) AppendFrom(other Set[T]) int { o := other.(*threadUnsafeSet[T])86:30exported-declaration-comment
threadunsafe.go:86:30
func (s *threadUnsafeSet[T]) Cardinality() int { return len(*s)90:30exported-declaration-comment
threadunsafe.go:90:30
func (s *threadUnsafeSet[T]) Clear() { // Constructions like this are optimised by compiler, and replaced by99:30exported-declaration-comment
threadunsafe.go:99:30
func (s *threadUnsafeSet[T]) Clone() Set[T] { t := threadUnsafeSet[T](mapclone(*s))104:30exported-declaration-comment
threadunsafe.go:104:30
func (s *threadUnsafeSet[T]) Contains(v ...T) bool { for _, val := range v {113:30exported-declaration-comment
threadunsafe.go:113:30
func (s *threadUnsafeSet[T]) ContainsOne(v T) bool { return s.contains(v)117:30exported-declaration-comment
threadunsafe.go:117:30
func (s *threadUnsafeSet[T]) ContainsAny(v ...T) bool { for _, val := range v {126:30cognitive-complexity
threadunsafe.go:126:30
func (s *threadUnsafeSet[T]) ContainsAnyElement(other Set[T]) bool { o := other.(*threadUnsafeSet[T])126:30exported-declaration-comment
threadunsafe.go:126:30
func (s *threadUnsafeSet[T]) ContainsAnyElement(other Set[T]) bool { o := other.(*threadUnsafeSet[T])127:12unchecked-type-assertion
threadunsafe.go:127:12
func (s *threadUnsafeSet[T]) ContainsAnyElement(other Set[T]) bool { o := other.(*threadUnsafeSet[T])147:30confusing-naming
threadunsafe.go:147:30
// private version of Contains for a single element vfunc (s *threadUnsafeSet[T]) contains(v T) (ok bool) { _, found := (*s)[v]152:30exported-declaration-comment
threadunsafe.go:152:30
func (s *threadUnsafeSet[T]) Difference(other Set[T]) Set[T] { o := other.(*threadUnsafeSet[T])153:12unchecked-type-assertion
threadunsafe.go:153:12
func (s *threadUnsafeSet[T]) Difference(other Set[T]) Set[T] { o := other.(*threadUnsafeSet[T])164:30exported-declaration-comment
threadunsafe.go:164:30
func (s *threadUnsafeSet[T]) Each(cb func(T) bool) { for elem := range *s {172:30exported-declaration-comment
threadunsafe.go:172:30
func (s *threadUnsafeSet[T]) Filter(cb func(T) bool) Set[T] { mappedSet := newThreadUnsafeSetWithSize[T](s.Cardinality())182:30exported-declaration-comment
threadunsafe.go:182:30
func (s *threadUnsafeSet[T]) Equal(other Set[T]) bool { o := other.(*threadUnsafeSet[T])183:12unchecked-type-assertion
threadunsafe.go:183:12
func (s *threadUnsafeSet[T]) Equal(other Set[T]) bool { o := other.(*threadUnsafeSet[T])196:30cognitive-complexity
threadunsafe.go:196:30
func (s *threadUnsafeSet[T]) Intersect(other Set[T]) Set[T] { o := other.(*threadUnsafeSet[T])196:30exported-declaration-comment
threadunsafe.go:196:30
func (s *threadUnsafeSet[T]) Intersect(other Set[T]) Set[T] { o := other.(*threadUnsafeSet[T])197:12unchecked-type-assertion
threadunsafe.go:197:12
func (s *threadUnsafeSet[T]) Intersect(other Set[T]) Set[T] { o := other.(*threadUnsafeSet[T])219:30exported-declaration-comment
threadunsafe.go:219:30
func (s *threadUnsafeSet[T]) IsEmpty() bool { return s.Cardinality() == 0223:30exported-declaration-comment
threadunsafe.go:223:30
func (s *threadUnsafeSet[T]) IsProperSubset(other Set[T]) bool { return s.Cardinality() < other.Cardinality() && s.IsSubset(other)224:9optimize-operands-order
threadunsafe.go:224:9
func (s *threadUnsafeSet[T]) IsProperSubset(other Set[T]) bool { return s.Cardinality() < other.Cardinality() && s.IsSubset(other)}227:30exported-declaration-comment
threadunsafe.go:227:30
func (s *threadUnsafeSet[T]) IsProperSuperset(other Set[T]) bool { return s.Cardinality() > other.Cardinality() && s.IsSuperset(other)228:9optimize-operands-order
threadunsafe.go:228:9
func (s *threadUnsafeSet[T]) IsProperSuperset(other Set[T]) bool { return s.Cardinality() > other.Cardinality() && s.IsSuperset(other)}231:30exported-declaration-comment
threadunsafe.go:231:30
func (s *threadUnsafeSet[T]) IsSubset(other Set[T]) bool { o := other.(*threadUnsafeSet[T])232:12unchecked-type-assertion
threadunsafe.go:232:12
func (s *threadUnsafeSet[T]) IsSubset(other Set[T]) bool { o := other.(*threadUnsafeSet[T]) if s.Cardinality() > other.Cardinality() {244:30exported-declaration-comment
threadunsafe.go:244:30
func (s *threadUnsafeSet[T]) IsSuperset(other Set[T]) bool { return other.IsSubset(s)248:30exported-declaration-comment
threadunsafe.go:248:30
func (s *threadUnsafeSet[T]) Iter() <-chan T { ch := make(chan T)260:30exported-declaration-comment
threadunsafe.go:260:30
func (s *threadUnsafeSet[T]) Iterator() *Iterator[T] { iterator, ch, stopCh := newIterator[T]()278:1doc-comment-period
threadunsafe.go:278:1
// Pop returns a popped item in case set is not empty, or nil-value of T// if set is already empty280:30exported-declaration-comment
threadunsafe.go:280:30
// if set is already emptyfunc (s *threadUnsafeSet[T]) Pop() (v T, ok bool) { for item := range *s {288:30exported-declaration-comment
threadunsafe.go:288:30
func (s *threadUnsafeSet[T]) PopN(n int) (items []T, count int) { if n <= 0 || len(*s) == 0 {294:3modifies-parameter
threadunsafe.go:294:3
if n > sn { n = sn }309:29exported-declaration-comment
threadunsafe.go:309:29
func (s threadUnsafeSet[T]) Remove(v T) { delete(s, v)313:29exported-declaration-comment
threadunsafe.go:313:29
func (s threadUnsafeSet[T]) RemoveAll(i ...T) { for _, elem := range i {328:30exported-declaration-comment
threadunsafe.go:328:30
func (s *threadUnsafeSet[T]) SymmetricDifference(other Set[T]) Set[T] { o := other.(*threadUnsafeSet[T])329:12unchecked-type-assertion
threadunsafe.go:329:12
func (s *threadUnsafeSet[T]) SymmetricDifference(other Set[T]) Set[T] { o := other.(*threadUnsafeSet[T])347:29exported-declaration-comment
threadunsafe.go:347:29
func (s threadUnsafeSet[T]) ToSlice() []T { keys := make([]T, 0, s.Cardinality())356:29exported-declaration-comment
threadunsafe.go:356:29
func (s threadUnsafeSet[T]) Union(other Set[T]) Set[T] { o := other.(*threadUnsafeSet[T])357:12unchecked-type-assertion
threadunsafe.go:357:12
func (s threadUnsafeSet[T]) Union(other Set[T]) Set[T] { o := other.(*threadUnsafeSet[T])372:1doc-comment-period
threadunsafe.go:372:1
// MarshalJSON creates a JSON array from the set, it marshals all elementsfunc (s threadUnsafeSet[T]) MarshalJSON() ([]byte, error) {379:7marshal-receiver
threadunsafe.go:379:7
// primitive types. Numbers are decoded as json.Number.func (s *threadUnsafeSet[T]) UnmarshalJSON(b []byte) error { var i []T379:30exported-declaration-comment
threadunsafe.go:379:30
// primitive types. Numbers are decoded as json.Number.func (s *threadUnsafeSet[T]) UnmarshalJSON(b []byte) error { var i []T391:29exported-declaration-comment
threadunsafe.go:391:29
// MarshalBSON creates a BSON array from the set.func (s threadUnsafeSet[T]) MarshalBSONValue() (bsontype.Type, []byte, error) { return bson.MarshalValue(s.ToSlice())396:29exported-declaration-comment
threadunsafe.go:396:29
// UnmarshalBSON recreates a set from a BSON array.func (s threadUnsafeSet[T]) UnmarshalBSONValue(bt bsontype.Type, b []byte) error { if bt != bson.TypeArray {398:10use-errors-new
threadunsafe.go:398:10
if bt != bson.TypeArray { return fmt.Errorf("must use BSON Array to unmarshal Set") }threadunsafe_test.go36
1:1format
threadunsafe_test.go:1:1
/*Open Source Initiative OSI - The MIT License (MIT):Licensing- Fix (safe): run `strider fmt threadunsafe_test.go`
26:9package-directory-mismatch
threadunsafe_test.go:26:9
package mapset33:6test-parallelism
threadunsafe_test.go:33:6
func TestThreadUnsafeSet_MarshalJSON(t *testing.T) { expected := NewThreadUnsafeSet[int64](1, 2, 3)40:12error-strings
threadunsafe_test.go:40:12
if err != nil { t.Errorf("Error should be nil: %v", err) }45:12error-strings
threadunsafe_test.go:45:12
if err != nil { t.Errorf("Error should be nil: %v", err) }49:12error-strings
threadunsafe_test.go:49:12
if !expected.Equal(actual) { t.Errorf("Expected no difference, got: %v", expected.Difference(actual)) }55:12add-constant
threadunsafe_test.go:55:12
if err != nil { t.Errorf("Error should be nil: %v", err) }55:12error-strings
threadunsafe_test.go:55:12
if err != nil { t.Errorf("Error should be nil: %v", err) }60:12error-strings
threadunsafe_test.go:60:12
if err != nil { t.Errorf("Error should be nil: %v", err) }64:12error-strings
threadunsafe_test.go:64:12
if !expected.Equal(actual) { t.Errorf("Expected no difference, got: %v", expected.Difference(actual)) }68:6test-parallelism
threadunsafe_test.go:68:6
func TestThreadUnsafeSet_UnmarshalJSON(t *testing.T) { expected := NewThreadUnsafeSet[int64](1, 2, 3)75:12error-strings
threadunsafe_test.go:75:12
if err != nil { t.Errorf("Error should be nil: %v", err) }78:12add-constant
threadunsafe_test.go:78:12
if !expected.Equal(actual) { t.Errorf("Expected no difference, got: %v", expected.Difference(actual)) }78:12error-strings
threadunsafe_test.go:78:12
if !expected.Equal(actual) { t.Errorf("Expected no difference, got: %v", expected.Difference(actual)) }85:12error-strings
threadunsafe_test.go:85:12
if err != nil { t.Errorf("Error should be nil: %v", err) }88:12error-strings
threadunsafe_test.go:88:12
if !expected.Equal(actual) { t.Errorf("Expected no difference, got: %v", expected.Difference(actual)) }92:6test-parallelism
threadunsafe_test.go:92:6
func TestThreadUnsafeSet_MarshalJSON_Struct(t *testing.T) { expected := &testStruct{"test", NewThreadUnsafeSet("a")}97:12error-strings
threadunsafe_test.go:97:12
if err != nil { t.Errorf("Error should be nil: %v", err) }103:12error-strings
threadunsafe_test.go:103:12
if err != nil { t.Errorf("Error should be nil: %v", err) }107:12error-strings
threadunsafe_test.go:107:12
if !expected.Set.Equal(actual.Set) { t.Errorf("Expected no difference, got: %v", expected.Set.Difference(actual.Set)) }110:6test-parallelism
threadunsafe_test.go:110:6
}func TestThreadUnsafeSet_UnmarshalJSON_Struct(t *testing.T) { expected := &testStruct{"test", NewThreadUnsafeSet("a", "b", "c")}111:26add-constant
threadunsafe_test.go:111:26
func TestThreadUnsafeSet_UnmarshalJSON_Struct(t *testing.T) { expected := &testStruct{"test", NewThreadUnsafeSet("a", "b", "c")} actual := &testStruct{}111:53add-constant
threadunsafe_test.go:111:53
func TestThreadUnsafeSet_UnmarshalJSON_Struct(t *testing.T) { expected := &testStruct{"test", NewThreadUnsafeSet("a", "b", "c")} actual := &testStruct{}116:12error-strings
threadunsafe_test.go:116:12
if err != nil { t.Errorf("Error should be nil: %v", err) }119:12error-strings
threadunsafe_test.go:119:12
if !expected.Set.Equal(actual.Set) { t.Errorf("Expected no difference, got: %v", expected.Set.Difference(actual.Set)) }122:40nested-structs
threadunsafe_test.go:122:40
expectedComplex := NewThreadUnsafeSet(struct{ Val string }{Val: "a"}, struct{ Val string }{Val: "b"}) actualComplex := NewThreadUnsafeSet[struct{ Val string }]()122:72nested-structs
threadunsafe_test.go:122:72
expectedComplex := NewThreadUnsafeSet(struct{ Val string }{Val: "a"}, struct{ Val string }{Val: "b"}) actualComplex := NewThreadUnsafeSet[struct{ Val string }]()123:38nested-structs
threadunsafe_test.go:123:38
expectedComplex := NewThreadUnsafeSet(struct{ Val string }{Val: "a"}, struct{ Val string }{Val: "b"}) actualComplex := NewThreadUnsafeSet[struct{ Val string }]()127:12error-strings
threadunsafe_test.go:127:12
if err != nil { t.Errorf("Error should be nil: %v", err) }130:12error-strings
threadunsafe_test.go:130:12
if !expectedComplex.Equal(actualComplex) { t.Errorf("Expected no difference, got: %v", expectedComplex.Difference(actualComplex)) }133:37nested-structs
threadunsafe_test.go:133:37
actualComplex = NewThreadUnsafeSet[struct{ Val string }]() err = json.Unmarshal([]byte(`[{"Val": "a"}, {"Val": "b"}]`), actualComplex)136:12error-strings
threadunsafe_test.go:136:12
if err != nil { t.Errorf("Error should be nil: %v", err) }139:12error-strings
threadunsafe_test.go:139:12
if !expectedComplex.Equal(actualComplex) { t.Errorf("Expected no difference, got: %v", expectedComplex.Difference(actualComplex)) }144:1top-level-declaration-order
threadunsafe_test.go:144:1
// this serves as an example of how to correctly unmarshal a struct with a Set propertytype testStruct struct { Other string149:22exported-declaration-comment
threadunsafe_test.go:149:22
func (t *testStruct) UnmarshalJSON(b []byte) error { raw := struct {150:9nested-structs
threadunsafe_test.go:150:9
func (t *testStruct) UnmarshalJSON(b []byte) error { raw := struct { Other string