Skip to content

Commit

Permalink
Fix errors in Dict class
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Sep 30, 2021
1 parent 36e8246 commit 00f0af9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions dict/dict.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (d *Dict) TryGetNumber(name string) (float64, bool) {

func (d *Dict) GetDict(name string) *Dict {
switch (*d)[name].(type) {
case interface{}:
case map[string]interface{}:
i := Dict((*d)[name].(map[string]interface{}))
return &i
}
Expand Down Expand Up @@ -80,15 +80,23 @@ func (d *Dict) GetFloat(name string, def float64) float64 {
func (d *Dict) GetUint8(name string, def uint8) uint8 {
switch (*d)[name].(type) {
case float64:
return uint8((*d)[name].(float64))
x := uint8((*d)[name].(float64))
// stupid check, but in some cases the output may be zero
if x != def {
return x
}
}
return def
}

func (d *Dict) GetUint16(name string, def uint16) uint16 {
switch (*d)[name].(type) {
case float64:
return uint16((*d)[name].(float64))
x := uint16((*d)[name].(float64))
// stupid check, but in some cases the output may be zero
if x != def {
return x
}
}
return def
}
Expand Down

0 comments on commit 00f0af9

Please sign in to comment.