Use Go slice in C
问题 I'm trying to build a go shared library with a function that returns a slice. How can I use the slice from C code ? package main import "C" type T struct { A C.int B *C.char } //export Test func Test() []T { arr := make([]T, 0) arr = append(arr, T{C.int(1), C.CString("a")}) arr = append(arr, T{C.int(2), C.CString("abc")}) return arr } func main() {} go build -o lib.so -buildmode=c-shared main.go I now have a lib.so and a lib.h What would be the C code to print the values of the array ?