diff options
Diffstat (limited to 'config.go')
-rw-r--r-- | config.go | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -3,15 +3,34 @@ package main import ( "encoding/json" "io" + "net" "os" "path/filepath" ) const configPathRelative = `.config/soundbox/config.json` +type MacAddress net.HardwareAddr + +func (m *MacAddress) UnmarshalJSON(data []byte) error { + var macStr string + err := json.Unmarshal(data, &macStr) + if err != nil { + return err + } + + hwAddr, err := net.ParseMAC(macStr) + if err != nil { + return err + } + + *m = MacAddress(hwAddr) + return nil +} + type SoundboxConfig struct { - Name string `json:"name"` - Mac string `json:"mac"` + Name string `json:"name"` + Mac MacAddress `json:"mac"` } type URLConfig struct { |