Skip to content

Commit

Permalink
del shadow var
Browse files Browse the repository at this point in the history
  • Loading branch information
korovindenis committed Apr 14, 2024
1 parent bb06a9e commit e847a3f
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 7 deletions.
1 change: 1 addition & 0 deletions internal/conn/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions internal/table/scanner/scan_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
3 changes: 2 additions & 1 deletion internal/topic/topicwriterinternal/writer_grpc_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions internal/value/nullable.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions internal/xstring/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ func Buffer() *buffer {
if !ok {
panic(fmt.Sprintf("unsupported type conversion from %T to *buffer", val))
}

return val
}
11 changes: 6 additions & 5 deletions log/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<nil>"
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 "<nil>"
}

Expand Down

0 comments on commit e847a3f

Please sign in to comment.