Gomobile绑定:不支持的基本类型:uint64

The documentation says that it should be supported. It seems that its not implemented in the gen.go file:

case types.Uint8: // types.Byte
        return "uint8_t"
    // TODO(crawshaw): case types.Uint, types.Uint16, types.Uint32, types.Uint64:

I read that i need to patch go mobile to support But after changing the file to support Uint64, (go/src/golang.org/x/mobile/bind/gen.go) And re init go mobile: gomobile init

The same error still appears, am i missing something obvious here?

I think the issue here is that Java does not have unsigned. Therefore interfaces to Java cannot have uint64 (and uint32 IIRC) file types as either global variables, function return values or function parameters.

You can use uint64 within Go mobile.

Two solutions based on the above:

  1. Limit the exposure of illegal types to Java to a minimum
  2. Convert uint64 to int64 in Go and convert from long to BigInteger in Java.

I solved this by patching Go mobile, inspired by this very StackOverflow post! I use "patch" very loosely, I don't encourage anyone to use this code as it is very purpose-specific.

I simply short-circuited the default case to return uint64 - you can see exactly what I did here: https://github.com/Sidetalker/mobile/commit/01eb11be69a781e71c7f00df6fc17b35f828f7a2

I needed to make a handful of other find/replace changes you can see on that branch to get it building properly, and I also had to fix what I'm pretty sure is a Go mobile bug with the byte type. All of this can be see on the branch.

Also, critically, I had to fully go get this project - making my changes and running gomobile init was not sufficient.

Don't use this code. Do mark this answered.