Skip to content

Commit

Permalink
fix nil point on json.unmarshal.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Aug 20, 2021
1 parent 23316c9 commit 4215459
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, &params); err != nil {
return nil, err
}

params.Name = name
return params, nil
return &params, nil
}

0 comments on commit 4215459

Please sign in to comment.