Skip to content

Commit

Permalink
Add functionality for parsing floats (google#338)
Browse files Browse the repository at this point in the history
* Add functionality for parsing floats

* Run gofmt on unpack.go

Co-authored-by: James <[email protected]>
  • Loading branch information
jammiess and james-a-johnson authored Jan 19, 2021
1 parent b6d3e7f commit 73f535f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions starlark/unpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ func unpackOneArg(v Value, ptr interface{}) error {
case *int, *int8, *int16, *int32, *int64,
*uint, *uint8, *uint16, *uint32, *uint64, *uintptr:
return AsInt(v, ptr)
case *float64:
f, ok := v.(Float)
if !ok {
return fmt.Errorf("got %s, want float", v.Type())
}
*ptr = float64(f)
case **List:
list, ok := v.(*List)
if !ok {
Expand Down

0 comments on commit 73f535f

Please sign in to comment.