From e847a3f23c5f088a4798ac50b6d69a4bfb3a2291 Mon Sep 17 00:00:00 2001 From: korovindenis Date: Sun, 14 Apr 2024 14:23:09 +0300 Subject: [PATCH] del shadow var --- internal/conn/conn.go | 1 + .../rawtopic/rawtopicwriter/streamwriter_test.go | 5 ++++- internal/table/scanner/scan_raw.go | 1 + .../topicwriterinternal/writer_grpc_mock_test.go | 3 ++- internal/value/nullable.go | 11 +++++++++++ internal/xstring/buffer.go | 1 + log/field.go | 11 ++++++----- 7 files changed, 26 insertions(+), 7 deletions(-) diff --git a/internal/conn/conn.go b/internal/conn/conn.go index 2fd03991e..d510c7ea4 100644 --- a/internal/conn/conn.go +++ b/internal/conn/conn.go @@ -569,6 +569,7 @@ func getContextMark(ctx context.Context) *modificationMark { if !ok { panic(fmt.Sprintf("unsupported type conversion from %T to *modificationMark", val)) } + return val } diff --git a/internal/grpcwrapper/rawtopic/rawtopicwriter/streamwriter_test.go b/internal/grpcwrapper/rawtopic/rawtopicwriter/streamwriter_test.go index b268ef0d7..2a962281b 100644 --- a/internal/grpcwrapper/rawtopic/rawtopicwriter/streamwriter_test.go +++ b/internal/grpcwrapper/rawtopic/rawtopicwriter/streamwriter_test.go @@ -73,10 +73,13 @@ func TestSendWriteRequest(t *testing.T) { } getWriteRequest := func(req *Ydb_Topic.StreamWriteMessage_FromClient) *Ydb_Topic.StreamWriteMessage_WriteRequest { + //nolint:protogetter res, ok := req.ClientMessage.(*Ydb_Topic.StreamWriteMessage_FromClient_WriteRequest) if !ok { - panic(fmt.Sprintf("unsupported type conversion from %T to *Ydb_Topic.StreamWriteMessage_FromClient_WriteRequest", res)) + panic(fmt.Sprintf(`unsupported type conversion from %T to + *Ydb_Topic.StreamWriteMessage_FromClient_WriteRequest`, res)) } + return res.WriteRequest } diff --git a/internal/table/scanner/scan_raw.go b/internal/table/scanner/scan_raw.go index c3b114c2d..dd3b81029 100644 --- a/internal/table/scanner/scan_raw.go +++ b/internal/table/scanner/scan_raw.go @@ -589,6 +589,7 @@ func isEqualDecimal(d *Ydb.DecimalType, t types.Type) bool { if !ok { panic(fmt.Sprintf("unsupported type conversion from %T to *types.Decimal", w)) } + return d.GetPrecision() == w.Precision() && d.GetScale() == w.Scale() } diff --git a/internal/topic/topicwriterinternal/writer_grpc_mock_test.go b/internal/topic/topicwriterinternal/writer_grpc_mock_test.go index 8139380cd..f0d047282 100644 --- a/internal/topic/topicwriterinternal/writer_grpc_mock_test.go +++ b/internal/topic/topicwriterinternal/writer_grpc_mock_test.go @@ -103,7 +103,8 @@ func (t *topicWriterOperationUnavailable) StreamWrite(server Ydb_Topic_V1.TopicS val, ok := messagesMsg.GetClientMessage().(*Ydb_Topic.StreamWriteMessage_FromClient_WriteRequest) if !ok { - panic(fmt.Sprintf("unsupported type conversion from %T to *Ydb_Topic.StreamWriteMessage_FromClient_WriteRequest", val)) + panic(fmt.Sprintf(`unsupported type conversion from %T + to *Ydb_Topic.StreamWriteMessage_FromClient_WriteRequest`, val)) } if len(val.WriteRequest.GetMessages()) == 0 { diff --git a/internal/value/nullable.go b/internal/value/nullable.go index ed03db18a..894b1ca8c 100644 --- a/internal/value/nullable.go +++ b/internal/value/nullable.go @@ -307,66 +307,77 @@ func Nullable(t types.Type, v interface{}) Value { if !ok { panic(fmt.Sprintf("unsupported type conversion from %T to TypeBool", tt)) } + return NullableBoolValue(tt) case types.Int8: tt, ok := v.(*int8) if !ok { panic(fmt.Sprintf("unsupported type conversion from %T to TypeBool", tt)) } + return NullableInt8Value(tt) case types.Uint8: tt, ok := v.(*uint8) if !ok { panic(fmt.Sprintf("unsupported type conversion from %T to TypeUint8", tt)) } + return NullableUint8Value(tt) case types.Int16: tt, ok := v.(*int16) if !ok { panic(fmt.Sprintf("unsupported type conversion from %T to TypeInt16", tt)) } + return NullableInt16Value(tt) case types.Uint16: tt, ok := v.(*uint16) if !ok { panic(fmt.Sprintf("unsupported type conversion from %T to TypeUint16", tt)) } + return NullableUint16Value(tt) case types.Int32: tt, ok := v.(*int32) if !ok { panic(fmt.Sprintf("unsupported type conversion from %T to TypeInt32", tt)) } + return NullableInt32Value(tt) case types.Uint32: tt, ok := v.(*uint32) if !ok { panic(fmt.Sprintf("unsupported type conversion from %T to Uint32", tt)) } + return NullableUint32Value(tt) case types.Int64: tt, ok := v.(*int64) if !ok { panic(fmt.Sprintf("unsupported type conversion from %T to TypeInt64", tt)) } + return NullableInt64Value(tt) case types.Uint64: tt, ok := v.(*uint64) if !ok { panic(fmt.Sprintf("unsupported type conversion from %T to TypeUint64", tt)) } + return NullableUint64Value(tt) case types.Float: tt, ok := v.(*float32) if !ok { panic(fmt.Sprintf("unsupported type conversion from %T to TypeFloat", tt)) } + return NullableFloatValue(tt) case types.Double: tt, ok := v.(*float64) if !ok { panic(fmt.Sprintf("unsupported type conversion from %T to TypeDouble", tt)) } + return NullableDoubleValue(tt) case types.Date: switch tt := v.(type) { diff --git a/internal/xstring/buffer.go b/internal/xstring/buffer.go index fcf29af47..da47a7756 100644 --- a/internal/xstring/buffer.go +++ b/internal/xstring/buffer.go @@ -24,5 +24,6 @@ func Buffer() *buffer { if !ok { panic(fmt.Sprintf("unsupported type conversion from %T to *buffer", val)) } + return val } diff --git a/log/field.go b/log/field.go index 9cc5dcd1a..cffaa648b 100644 --- a/log/field.go +++ b/log/field.go @@ -170,15 +170,16 @@ func (f Field) String() string { case StringsType: return fmt.Sprintf("%v", f.StringsValue()) case ErrorType: - val, ok := f.vany.(error) - if val == nil { - return "" + if f.vany == nil { + return nilPtr } + + val, ok := f.vany.(error) if !ok { - panic(fmt.Sprintf("unsupported type conversion from %T to error", val)) + panic(fmt.Sprintf("unsupported type conversion from %T to fmt.Stringer", val)) } - if f.vany == nil { + if val == nil { return "" }