make configs settable
This commit is contained in:
parent
3789178234
commit
163f11c397
3 changed files with 40 additions and 0 deletions
16
ipconfig.go
16
ipconfig.go
|
|
@ -8,6 +8,22 @@ import (
|
|||
|
||||
type IPConfigs []*IPConfig
|
||||
|
||||
func (c *IPConfigs) Set(index int, ipc *IPConfig) {
|
||||
l := len(*c)
|
||||
if index >= l {
|
||||
n := make(IPConfigs, index+1)
|
||||
copy(n, *c)
|
||||
n[index] = ipc
|
||||
*c = n
|
||||
return
|
||||
}
|
||||
if l == 0 {
|
||||
*c = append(*c, ipc)
|
||||
return
|
||||
}
|
||||
(*c)[index] = ipc
|
||||
}
|
||||
|
||||
func (c IPConfigs) Get(index int) *IPConfig {
|
||||
if len(c)-1 >= index {
|
||||
return c[index]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue