forked from heierbtc/satdress-mirror
fix nil point on json.unmarshal.
This commit is contained in:
parent
23316c9af8
commit
42154594c9
8
db.go
8
db.go
|
@ -48,16 +48,18 @@ func SaveName(name string, params *Params, providedPin string) (pin string, err
|
|||
return pin, nil
|
||||
}
|
||||
|
||||
func GetName(name string) (params *Params, err error) {
|
||||
func GetName(name string) (*Params, error) {
|
||||
val, closer, err := db.Get([]byte(name))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer closer.Close()
|
||||
if err := json.Unmarshal(val, params); err != nil {
|
||||
|
||||
var params Params
|
||||
if err := json.Unmarshal(val, ¶ms); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
params.Name = name
|
||||
return params, nil
|
||||
return ¶ms, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user