From bb48d416fcc40b941ddf61b3b377c724932559d2 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 29 Feb 2024 17:19:57 +0200 Subject: [PATCH] lib/protoparser/csvimport: unse unsafe.Slice instead of deprecated reflect.SliceHeader --- .../csvimport/column_descriptor_test.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/lib/protoparser/csvimport/column_descriptor_test.go b/lib/protoparser/csvimport/column_descriptor_test.go index 11fad99c8..85a093b31 100644 --- a/lib/protoparser/csvimport/column_descriptor_test.go +++ b/lib/protoparser/csvimport/column_descriptor_test.go @@ -3,7 +3,6 @@ package csvimport import ( "bytes" "fmt" - "reflect" "testing" "time" "unsafe" @@ -201,17 +200,8 @@ func equalColumnDescriptors(a, b []ColumnDescriptor) bool { } func equalColumnDescriptor(x, y ColumnDescriptor) bool { - var b1, b2 []byte - - sh1 := (*reflect.SliceHeader)(unsafe.Pointer(&b1)) - sh1.Data = uintptr(unsafe.Pointer(&x.ParseTimestamp)) - sh1.Len = int(unsafe.Sizeof(x.ParseTimestamp)) - sh1.Cap = int(unsafe.Sizeof(x.ParseTimestamp)) - - sh2 := (*reflect.SliceHeader)(unsafe.Pointer(&b2)) - sh2.Data = uintptr(unsafe.Pointer(&y.ParseTimestamp)) - sh2.Len = int(unsafe.Sizeof(y.ParseTimestamp)) - sh2.Cap = int(unsafe.Sizeof(y.ParseTimestamp)) + b1 := unsafe.Slice((*byte)(unsafe.Pointer(&x.ParseTimestamp)), int(unsafe.Sizeof(x.ParseTimestamp))) + b2 := unsafe.Slice((*byte)(unsafe.Pointer(&y.ParseTimestamp)), int(unsafe.Sizeof(y.ParseTimestamp))) if !bytes.Equal(b1, b2) { return false