我有一个日志文件如下:
{"L":"DEBUG","T":"2021-11-01T17:37:54.167+0530","M":"Route.go:74[IN : GetLatestLogs]"}
{"L":"DEBUG","T":"2021-11-01T17:37:54.167+0530","M":"Service.go:40[IN : GetRecentServerErrorLogService]"}
{"L":"DEBUG","T":"2021-11-01T17:37:54.167+0530","M":"DAO.go:117[IN : GetRecentServerErrorLogDAO]"}
{"L":"DEBUG","T":"2021-11-01T17:37:54.168+0530","M":"DAO.go:148[OUT : GetRecentServerErrorLogDAO]"}
{"L":"DEBUG","T":"2021-11-01T17:37:54.168+0530","M":"Service.go:47[OUT : GetRecentServerErrorLogService]"}
{"L":"DEBUG","T":"2021-11-01T17:37:54.168+0530","M":"Route.go:79[OUT : GetLatestLogs]"}
{"L":"DEBUG","T":"2021-11-01T17:40:55.331+0530","M":"Route.go:74[IN : GetLatestLogs]"}
我正在 Golang 回显服务器中读取此文件,如下所示:
file, err := os.Open(logFilePath)
stat, _ := os.Stat(logFilePath)
buf := make([]byte, stat.Size())
_, err = file.Read(buf)
serverLog := string(buf)
并返回生成的这个字符串
return c.JSON(http.StatusOK, serverLog)
我想将此收到的响应转换为 JSON 对象。
人到中年有点甜
GCT1015
交互式爱情
相关分类