I want to send the string to the server.My string is like as below,
str := "[{\"name\":\"cpu\",\"status\":\"%d\"}, {\"name\":\"LTE\",\"status\":\"%d\"}, {\"name\":\"Network\",\"status\":\"%d\"}, {\"name\":\"Memory\",\"status\":\"%d\"}]"
When I print it using "fmt.Println(str)",it gives desired output as below,
[{"name":"cpu","status":"%d"}, {"name":"LTE","status":"%d"}, {"name":"Network","status":"%d"}, {"name":"Memory","status":"%d"}]
But when I am sending same string to server,server receives string as below,
"[{\"name\":\"cpu\",\"status\":\"%d\"}, {\"name\":\"LTE\",\"status\":\"%d\"}, {\"name\":\"Network\",\"status\":\"%d\"}, {\"name\":\"Memory\",\"status\":\"%d\"}]"
Please find my code snippet as below:
func (m *MetricSet) Fetch() (common.MapStr, error) {
var x string
x =fmt.Sprintf("[{\"name\":\"cpu\",\"status\":\"%d\"}, {\"name\":\"LTE\",\"status\":\"%d\"}, {\"name\":\"Network\",\"status\":\"%d\"}, {\"name\":\"Memory\",\"status\":\"%d\"}]", 17,26,34,33)
fmt.Println(x)
event := common.MapStr{
"cpu_status": (m.cpu_status%4),
"memory_status" : (m.memory_status%4),
"lte_status" : (m.lte_status%4),
"network_status" : (m.network_status%4),
"summary": x,
}
m.cpu_status++
m.memory_status = m.memory_status + 2
m.lte_status = m.lte_status + 7
m.network_status = m.network_status + 13
return event, nil
}
How to solve it?Please help me.