modify and add new fields for drivers
This commit is contained in:
25
models/driver.go
Normal file
25
models/driver.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package models
|
||||
|
||||
// driver model
|
||||
type Driver struct {
|
||||
Type string `json:"type"` // driver type name of driver in collection
|
||||
Buses map[string]*Bus `json:"buses"` // name of driver bus
|
||||
}
|
||||
|
||||
func (d *Driver) AddBus(name string) *Bus {
|
||||
if d.Buses == nil {
|
||||
d.Buses = make(map[string]*Bus)
|
||||
}
|
||||
if b, ok := d.Buses[name]; ok {
|
||||
return b
|
||||
}
|
||||
d.Buses[name] = &Bus{Name: name}
|
||||
return d.Buses[name]
|
||||
}
|
||||
|
||||
func (d *Driver) GetBus(name string) *Bus {
|
||||
if b, ok := d.Buses[name]; ok {
|
||||
return b
|
||||
}
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user