Hello,
I have a problem with structs:
I defined the following structs:
type Value struct {
Type string `json:"type"`
Unity string `json:"unity"`
Data float64 `json:"data"`
}
type Phase struct {
Phase int `json:"phase"`
Name string `json:"name"`
Values []Value `json:"values"`
}
type Dataset struct {
Time string `json:"time"`
Phases []Phase `json:"phases"`
}
type Measurement struct {
Serial string `json:"serial"`
Time string `json:"time"`
Softwareversion string `json:"softwareversion"`
Ipaddress string `json:"ipaddress"`
Datasets []Dataset `json:"datasets"`
}
At compiling, I get an error (cannot use Value literal (type Value) as type []Value in field value) at the following line
Type: "current", Unity: "A", Data: 1.879352},
measurement := Measurement{
Serial: "SmartPi12345",
Time: "0001-01-01T00:00:00Z",
Softwareversion: "1.0.1",
Ipaddress: "192.168.2.10",
Datasets: Dataset{
Time: "0001-01-02T00:00:00Z",
Phases: Phase{
Phase: 1, Name: "phase 1",
Values: Value{
Type: "current", Unity: "A", Data: 1.879352},
},
},
}
Can someone help me. I don't find an error.
Best regards Jens