make configs settable

This commit is contained in:
ston1th 2020-06-01 16:35:35 +02:00
commit 163f11c397
3 changed files with 40 additions and 0 deletions

View file

@ -9,6 +9,22 @@ import (
type NetworkDevices []*NetworkDevice
func (c *NetworkDevices) Set(index int, d *NetworkDevice) {
l := len(*c)
if index >= l {
n := make(NetworkDevices, index+1)
copy(n, *c)
n[index] = d
*c = n
return
}
if l == 0 {
*c = append(*c, d)
return
}
(*c)[index] = d
}
func (c NetworkDevices) Get(index int) *NetworkDevice {
if len(c)-1 >= index {
return c[index]