The problem of js receiving data of int64 type in golang output

the server uses the go language, and the json output by the framework iris contains data of int64 type: 7156182378476995584 js has changed the value after receiving it, changing to: 7156182378476996000

the problem is mainly on the server side:

clipboard.png
this struct is the Uid bit in the data, I want to output. I want to convert it to string, on output. Is there any elegant way to handle it except through the for loop

Mar.19,2021

this is obviously overflowed. The computer does not support such a large number. You can choose to change the number into a string


js value will lose precision by manipulating Math.pow (2,53). It can be converted to a string


so that this structure of go can implement the Marshaler interface. In the interface implementation, change the value of the Uid attribute to a string, so that the Uid attribute in the JSON structure serialized into the structure body is a string.

Menu