Skip to content

Commit 033db56

Browse files
committed
add special type for *float64 and ignore fix bug when using []time.Time
1 parent 69bb178 commit 033db56

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

generator/generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
const (
13-
Version = "0.9.0"
13+
Version = "0.9.1"
1414
defaultFileHeader = `Code generated by microgen ` + Version + `. DO NOT EDIT.`
1515
)
1616

generator/template/transport_grpc_client.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ func specialReplyType(p types.Type) *Statement {
130130
return (&Statement{}).Qual(GolangProtobufWrappers, "StringValue").Values()
131131
}
132132
}
133+
// *float64 -> *wrappers.DoubleValue
134+
if name != nil && *name == "float64" && imp == nil {
135+
ptr, ok := p.(types.TPointer)
136+
if ok && ptr.NumberOfPointers == 1 {
137+
return (&Statement{}).Qual(GolangProtobufWrappers, "DoubleValue").Values()
138+
}
139+
}
133140
return nil
134141
}
135142

generator/template/transport_grpc_protobuf_type_converters.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ func specialTypeConverter(p types.Type) *Statement {
4242
}
4343
// time.Time -> timestamp.Timestamp
4444
if name != nil && *name == "Time" && imp != nil && imp.Package == "time" {
45-
return Op("*").Qual(GolangProtobufPtypesTimestamp, "Timestamp")
45+
if types.TypeArray(p) == nil { // ignore []time.Time case
46+
return Op("*").Qual(GolangProtobufPtypesTimestamp, "Timestamp")
47+
}
4648
}
4749
// jsonb.JSONB -> string
4850
if name != nil && *name == "JSONB" && imp != nil && imp.Package == JsonbPackage {
@@ -55,6 +57,13 @@ func specialTypeConverter(p types.Type) *Statement {
5557
return Op("*").Qual(GolangProtobufWrappers, "StringValue")
5658
}
5759
}
60+
// *float64 -> *wrappers.DoubleValue
61+
if name != nil && *name == "float64" && imp == nil {
62+
ptr, ok := p.(types.TPointer)
63+
if ok && ptr.NumberOfPointers == 1 {
64+
return (&Statement{}).Qual(GolangProtobufWrappers, "DoubleValue").Values()
65+
}
66+
}
5867
return nil
5968
}
6069

0 commit comments

Comments
 (0)