From []byte to char*

后端 未结 1 992
花落未央
花落未央 2021-02-07 23:43

I want to wrap a C function that takes a char* pointing to (the first element of) a non-empty buffer of bytes. I\'m trying to wrap that in a Go function using CGo s

相关标签:
1条回答
  • 2021-02-08 00:14

    Ok, that turned out to be much easier than I thought:

    (*C.char)(unsafe.Pointer(&b[0]))
    

    does the trick. (Found this at golang-nuts.)

    0 讨论(0)
提交回复
热议问题