我正在GKE上运行Go应用程序。 我在应用程序中输出JSON日志。 使用Stackdriver Logging检查日志时,数值错误。
我们如何解决这个问题?
import (
"encoding/json"
"fmt"
)
type Value struct {
V int64
S string
}
func log(num int64) {
v := Value{
V: num,
S: fmt.Sprint(num),
}
j, err := json.Marshal(v)
if err != nil {
panic(err)
}
fmt.Printf("%d\n", uint64(num))
fmt.Println(string(j))
}
即使使用gcloud命令,我也注意到该值中存在错误。 Stackdriver Logging的服务器端是否有错误?
gcloud logging write projects/gcpugjp/logs/bignum --payload-type=json '{"num": 36028797018963966, "text": "36028797018963966"}'
gcloud logging read projects/gcpugjp/logs/bignum
---
insertId: 1f25wvtf1b5rsv
jsonPayload:
num: 36028797018963968
text: '36028797018963966'
logName: projects/gcpugjp/logs/bignum
receiveTimestamp: '2018-10-02T10:20:21.734286025Z'
resource:
labels:
project_id: gcpugjp
type: global
timestamp: '2018-10-02T10:20:21.734286025Z'
---