package sensor import ( "fmt" "sync" ) /* this file serves as a map that the sensor library can use to determine which manager to call */ type NewManager interface { // serves as interface to restrict managers can be relocated } type DM struct { DeviceManagers map[uint]NewManager sync.Mutex } func NewManagerDirectory() *DM { m := map[uint]NewManager{ // map to set functions up 112: NewDOManager(), } return &DM{DeviceManagers: m} } func (d *DM) GetManager(addr uint) (NewManager, error) { d.Lock() defer d.Unlock() if m, ok := d.DeviceManagers[addr]; ok { return m, nil } return &DM{}, fmt.Errorf("No manager found for address %d!", addr) }