Skip to content

Commit

Permalink
Fix map string decode hook
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelreiswildlife committed Sep 21, 2023
1 parent ec879c8 commit d44c2ca
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,17 @@ func StringToMapBoolHookFunc() mapstructure.DecodeHookFunc {
return map[string]bool{}, nil
}

m := map[string]bool{}
err := json.Unmarshal([]byte(raw), &m)
return m, err
unmarshalled := map[string]string{}
err := json.Unmarshal([]byte(raw), &unmarshalled)
if err != nil {
return map[string]bool{}, err
}

result := map[string]bool{}
for k, v := range unmarshalled {
result[k] = v == "true"
}

return result, err
}
}

0 comments on commit d44c2ca

Please sign in to comment.