26 lines
642 B
Go
26 lines
642 B
Go
package models
|
|
|
|
// collection of drivers ordered in map
|
|
type Drivers map[string]*Driver
|
|
|
|
// driver model
|
|
type Driver struct {
|
|
Type string `json:"type,omitempty"` // driver type name of driver in collection
|
|
Bus string `json:"bus"` // name of driver bus
|
|
Address uint `json:"address"` // address of bus
|
|
}
|
|
|
|
// returns a new collection of drivers
|
|
func NewDrivers() Drivers {
|
|
return make(Drivers)
|
|
}
|
|
|
|
// Add new driver to driver collection
|
|
// typ is the name of the driver in driver collection
|
|
func (d *Drivers) AddDriver(typ, bus string, address uint) {
|
|
(*d)[typ] = &Driver{
|
|
Bus: bus,
|
|
Address: address,
|
|
}
|
|
}
|