Use constructor functions for FolderConfiguration and DeviceConfiguration
This commit is contained in:
@@ -17,6 +17,13 @@ type DeviceConfiguration struct {
|
||||
Introducer bool `xml:"introducer,attr" json:"introducer"`
|
||||
}
|
||||
|
||||
func NewDeviceConfiguration(id protocol.DeviceID, name string) DeviceConfiguration {
|
||||
return DeviceConfiguration{
|
||||
DeviceID: id,
|
||||
Name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func (orig DeviceConfiguration) Copy() DeviceConfiguration {
|
||||
c := orig
|
||||
c.Addresses = make([]string, len(orig.Addresses))
|
||||
|
||||
@@ -44,6 +44,15 @@ type FolderDeviceConfiguration struct {
|
||||
DeviceID protocol.DeviceID `xml:"id,attr" json:"deviceID"`
|
||||
}
|
||||
|
||||
func NewFolderConfiguration(id, path string) FolderConfiguration {
|
||||
f := FolderConfiguration{
|
||||
ID: id,
|
||||
RawPath: path,
|
||||
}
|
||||
f.prepare()
|
||||
return f
|
||||
}
|
||||
|
||||
func (f FolderConfiguration) Copy() FolderConfiguration {
|
||||
c := f
|
||||
c.Devices = make([]FolderDeviceConfiguration, len(f.Devices))
|
||||
|
||||
Reference in New Issue
Block a user