THRIFT-3467 Go Maps for Thrift Sets Should Have Values of Type struct{}
Client: Go
Patch: artem antonenko <sam901@yandex.ru>
This closes #976
diff --git a/lib/go/test/tests/client_error_test.go b/lib/go/test/tests/client_error_test.go
index 829a1dd..838883d 100644
--- a/lib/go/test/tests/client_error_test.go
+++ b/lib/go/test/tests/client_error_test.go
@@ -402,7 +402,7 @@
thing := errortest.NewTestStruct()
thing.M = make(map[string]string)
thing.L = make([]string, 0)
- thing.S = make(map[string]bool)
+ thing.S = make(map[string]struct{})
thing.I = 3
err := thrift.NewTTransportException(thrift.TIMED_OUT, "test")
@@ -434,7 +434,7 @@
thing := errortest.NewTestStruct()
thing.M = make(map[string]string)
thing.L = make([]string, 0)
- thing.S = make(map[string]bool)
+ thing.S = make(map[string]struct{})
thing.I = 3
err := thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, errors.New("test"))
diff --git a/lib/go/test/tests/thrifttest_driver.go b/lib/go/test/tests/thrifttest_driver.go
index 915383f..1e0cf86 100644
--- a/lib/go/test/tests/thrifttest_driver.go
+++ b/lib/go/test/tests/thrifttest_driver.go
@@ -162,7 +162,7 @@
t.Fatal("TestStringMap failed")
}
- setTestInput := map[int32]bool{1: true, 2: true, 3: true}
+ setTestInput := map[int32]struct{}{1: {}, 2: {}, 3: {}}
if r, err := client.TestSet(setTestInput); !reflect.DeepEqual(r, setTestInput) || err != nil {
t.Fatal("TestSet failed")
}
diff --git a/lib/go/test/tests/thrifttest_handler.go b/lib/go/test/tests/thrifttest_handler.go
index 50fe718..822a6c7 100644
--- a/lib/go/test/tests/thrifttest_handler.go
+++ b/lib/go/test/tests/thrifttest_handler.go
@@ -96,7 +96,7 @@
return thing, nil
}
-func (p *ThriftTestHandler) TestSet(thing map[int32]bool) (r map[int32]bool, err error) {
+func (p *ThriftTestHandler) TestSet(thing map[int32]struct{}) (r map[int32]struct{}, err error) {
return thing, nil
}
diff --git a/lib/go/thrift/serializer_test.go b/lib/go/thrift/serializer_test.go
index 3cdb387..06d27a1 100644
--- a/lib/go/thrift/serializer_test.go
+++ b/lib/go/thrift/serializer_test.go
@@ -85,7 +85,7 @@
m.Bin = make([]byte, 10)
m.StringMap = make(map[string]string, 5)
m.StringList = make([]string, 5)
- m.StringSet = make(map[string]bool, 5)
+ m.StringSet = make(map[string]struct{}, 5)
m.E = 2
s, err := t.WriteString(&m)
@@ -119,7 +119,7 @@
m.Bin = make([]byte, 10)
m.StringMap = make(map[string]string, 5)
m.StringList = make([]string, 5)
- m.StringSet = make(map[string]bool, 5)
+ m.StringSet = make(map[string]struct{}, 5)
m.E = 2
s, err := t.WriteString(&m)
diff --git a/lib/go/thrift/serializer_types_test.go b/lib/go/thrift/serializer_types_test.go
index 10f4737..38ab8d6 100644
--- a/lib/go/thrift/serializer_types_test.go
+++ b/lib/go/thrift/serializer_types_test.go
@@ -97,18 +97,18 @@
func MyTestEnumPtr(v MyTestEnum) *MyTestEnum { return &v }
type MyTestStruct struct {
- On bool `thrift:"on,1" json:"on"`
- B int8 `thrift:"b,2" json:"b"`
- Int16 int16 `thrift:"int16,3" json:"int16"`
- Int32 int32 `thrift:"int32,4" json:"int32"`
- Int64 int64 `thrift:"int64,5" json:"int64"`
- D float64 `thrift:"d,6" json:"d"`
- St string `thrift:"st,7" json:"st"`
- Bin []byte `thrift:"bin,8" json:"bin"`
- StringMap map[string]string `thrift:"stringMap,9" json:"stringMap"`
- StringList []string `thrift:"stringList,10" json:"stringList"`
- StringSet map[string]bool `thrift:"stringSet,11" json:"stringSet"`
- E MyTestEnum `thrift:"e,12" json:"e"`
+ On bool `thrift:"on,1" json:"on"`
+ B int8 `thrift:"b,2" json:"b"`
+ Int16 int16 `thrift:"int16,3" json:"int16"`
+ Int32 int32 `thrift:"int32,4" json:"int32"`
+ Int64 int64 `thrift:"int64,5" json:"int64"`
+ D float64 `thrift:"d,6" json:"d"`
+ St string `thrift:"st,7" json:"st"`
+ Bin []byte `thrift:"bin,8" json:"bin"`
+ StringMap map[string]string `thrift:"stringMap,9" json:"stringMap"`
+ StringList []string `thrift:"stringList,10" json:"stringList"`
+ StringSet map[string]struct{} `thrift:"stringSet,11" json:"stringSet"`
+ E MyTestEnum `thrift:"e,12" json:"e"`
}
func NewMyTestStruct() *MyTestStruct {
@@ -155,7 +155,7 @@
return p.StringList
}
-func (p *MyTestStruct) GetStringSet() map[string]bool {
+func (p *MyTestStruct) GetStringSet() map[string]struct{} {
return p.StringSet
}
@@ -366,7 +366,7 @@
if err != nil {
return PrependError("error reading set begin: ", err)
}
- tSet := make(map[string]bool, size)
+ tSet := make(map[string]struct{}, size)
p.StringSet = tSet
for i := 0; i < size; i++ {
var _elem3 string
@@ -375,7 +375,7 @@
} else {
_elem3 = v
}
- p.StringSet[_elem3] = true
+ p.StringSet[_elem3] = struct{}{}
}
if err := iprot.ReadSetEnd(); err != nil {
return PrependError("error reading set end: ", err)