File tree Expand file tree Collapse file tree 3 files changed +526
-505
lines changed Expand file tree Collapse file tree 3 files changed +526
-505
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,15 @@ func ifaceSliceToString(v interface{}) string {
4040 }
4141 return string(b)
4242}
43+
44+ // toStruct converts a union to a struct with all fields optional.
45+ func unionToStruct(u union) *Struct {
46+ st := (*Struct)(u)
47+ for _, f := range st.Fields {
48+ f.Optional = true
49+ }
50+ return st
51+ }
4352}
4453
4554Grammar ← __ statements:( Statement __ )* (EOF / SyntaxError) {
@@ -70,7 +79,7 @@ Grammar ← __ statements:( Statement __ )* (EOF / SyntaxError) {
7079 case exception:
7180 thrift.Exceptions[v.Name] = (*Struct)(v)
7281 case union:
73- thrift.Unions[v.Name] = (*Struct) (v)
82+ thrift.Unions[v.Name] = unionToStruct (v)
7483 case *Service:
7584 thrift.Services[v.Name] = v
7685 case include:
You can’t perform that action at this time.
0 commit comments