mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-04 07:45:30 +00:00
15 lines
199 B
Go
15 lines
199 B
Go
package util
|
|
|
|
import "encoding/json"
|
|
|
|
func MapToStruct(s any, v any) error {
|
|
if s == nil {
|
|
return nil
|
|
}
|
|
b, err := json.Marshal(s)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return json.Unmarshal(b, v)
|
|
}
|