mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Move mapping functions to db_ledis, where it is used
This commit is contained in:
parent
52fc580a2b
commit
93ab4132fe
2 changed files with 6 additions and 6 deletions
|
@ -1,30 +0,0 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
func ToMap(rec interface{}) (map[string]interface{}, error) {
|
||||
// Convert to JSON...
|
||||
b, err := json.Marshal(rec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// ... then convert to map
|
||||
var m map[string]interface{}
|
||||
err = json.Unmarshal(b, &m)
|
||||
return m, err
|
||||
}
|
||||
|
||||
func ToStruct(m map[string]interface{}, rec interface{}) error {
|
||||
// Convert to JSON...
|
||||
b, err := json.Marshal(m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// ... then convert to struct
|
||||
err = json.Unmarshal(b, &rec)
|
||||
return err
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue