Hello ,
I am beginner in go , and i would like to send uint8_t array from C to GO, but when i send my array like pointer, i don’t know how i can read it and save it in GO like byte[] array type .
Here is my code :
package main
/*
#include <stdint.h>
uint8_t Plaintext[16] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
uint8_t * send_data( )
{
return Plaintext;
}
*/
import "C"
import "unsafe"
import "fmt"
func main() {
data := [16]byte{}
p := C.send_data()
//already try data = C.send_data()
fmt.Println(p)
data = p // don't know how do this ?
}
The objectif is to have data byte array in go like :
data[16] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}
I try lot of solution, but every time i have log that say " cannot use (func literal)() (type *_Ctype_uchar) as type"uint8" or “byte” …
Thanks guys for your help !