github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/convert/bool-slice-unsafe.go (about) 1 /* For license and copyright information please see LEGAL file in repository */ 2 3 package convert 4 5 import ( 6 "reflect" 7 "unsafe" 8 ) 9 10 // UnsafeBoolSliceToByteSlice returns ... 11 func UnsafeBoolSliceToByteSlice(req []bool) (res []byte) { 12 var reqStruct = (*reflect.SliceHeader)(unsafe.Pointer(&req)) 13 var resStruct = (*reflect.SliceHeader)(unsafe.Pointer(&res)) 14 resStruct.Data = reqStruct.Data 15 resStruct.Len = reqStruct.Len 16 resStruct.Cap = reqStruct.Cap 17 return 18 } 19 20 // UnsafeByteSliceToBoolSlice returns ... 21 func UnsafeByteSliceToBoolSlice(req []byte) (res []bool) { 22 var reqStruct = (*reflect.SliceHeader)(unsafe.Pointer(&req)) 23 var resStruct = (*reflect.SliceHeader)(unsafe.Pointer(&res)) 24 resStruct.Data = reqStruct.Data 25 resStruct.Len = reqStruct.Len 26 resStruct.Cap = reqStruct.Cap 27 return 28 }