Hello! I am working on a home automation project in Go.
One of the components is polling all the sensors in a HUE bridge (this is some LED lighting system with smart lamps and buttons). I am wanting to make a map, keyed on int to "Sensor" objects. These objects are located in a sensors package (so: sensors.Sensor). My noob feeling says to do it like this: var previousSensorInfo map[int]sensors.Sensor = make(map[int]sensors.Sensor) but the compiler says: *src/github.com/cpo/events/bridges/hue/hue.go:91:40: sensors.Sensor undefined (type *sensors.Sensors has no field or method Sensor)* (this is the line indicated above) This sensors.Sensor type is a simple struct: type Sensor struct { ID int `json:"id,omitempty"` Name string `json:"name"` State State `json:"state,omitempty"` Config Config `json:"config,omitempty"` Type string `json:"type,omitempty"` ModelID string `json:"modelid,omitempty"` SWVersion string `json:"swversion,omitempty"` ManufacturerName string `json:"manufacturername,omitempty"` UniqueID string `json:"uniqueid,omitempty"` } The full code reads: func (hue *HueBridge) pollSensors(sensors *sensors.Sensors) { var previousSensorInfo map[int]sensors.Sensor = make(map[int]sensors.Sensor) for true { logger.Printf("Polling sensors") sensorInfo, err := sensors.GetAllSensors() if err == nil { if previousSensorInfo == nil { // first call logger.Printf("Got %d sensors", len(sensorInfo)) for _, sensor := range sensorInfo { previousSensorInfo[sensor.ID] = &sensor } } else { // diff the two for _, sensor := range sensorInfo { prevSensor, found := previousSensorInfo[sensor.ID] if found { if hue.diffSensor(prevSensor, sensor) { logger.Printf(" Previous: %s", prevSensor) logger.Printf(" Now : %s", sensor) } } else { logger.Printf("New sensor: %d", sensor.ID) } previousSensorInfo[sensor.ID] = sensor } } } time.Sleep(1 * time.Second) } } What is going on here? Regards, Chris -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.