ebitengine / purego

Apache License 2.0
2.16k stars 68 forks source link

How to receive uint8_t * in golang #164

Closed Cyberhan123 closed 1 year ago

Cyberhan123 commented 1 year ago

The C code is

uint8_t * function img(){
  std::vector<uint8_t> result;
  static auto *data = (uint8_t *) result.data();
  return data;
}

How to receive uint8_t * in golang

By the way, it is actually a picture. I feel that the mapping in golang is []byte

TotallyGamerJet commented 1 year ago

Please review the docs for RegisterFunc. A uint8_t * would be *uint8 or *byte. You can then make it a slice if you know the size using unsafe.Slice(data, dataSize)

TotallyGamerJet commented 1 year ago

Closing as this is not an issue. Future questions can be directed to the Discord.

Cyberhan123 commented 1 year ago

Thanks for your help.