I am running Go application on GKE. I output the JSON log in the application. When checking the log with Stackdriver Logging, there is an error in the numerical value.
How can we solve this?
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))
}
Even I gcloud command, I noticed that there was an error in the value. Is there an error on the Server side of 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'
---