从golang的fixed64 protobuf字段读取int64

I have a field that is of type fixed64 in a .proto file.

I want to read it as an int64 field:

score := int64(pb_obj.Score)

When I try to compile the line agove I get the error message cannot convert pb_obj.Score (type *uint64) to type int64. I tried converting the a uint64 as well, and got an almost identical message.

pb_obj.Score's type seems to be *uint64 (pointer to uint64), not uint64. You just need to access to the value the pointer is referencing:

score := int64(*pb_obj.Score)

(See the * prefix as the difference)

Based on the compile error you're working with a uint64 pointer and not a uint64 value. You may get what you want by referencing the value directly using the * operator. I've never worked with protobuf, so I could be off but that should get you moving. Here's a nice reference that may help golang pointers