diff options
author | James Johnson <63020180+jammiess@users.noreply.github.com> | 2021-01-19 11:24:22 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-19 11:24:22 -0500 |
commit | 73f535f109ef395b6b65c1161f74bc5ae9e6ae92 (patch) | |
tree | 4d245f69a579352c9640fc5646d0984e570e7e46 | |
parent | b6d3e7f4b0f5b20e6b08b4755a94ac7eab8981d0 (diff) | |
download | starlark-go-73f535f109ef395b6b65c1161f74bc5ae9e6ae92.tar.gz |
Add functionality for parsing floats (#338)
* Add functionality for parsing floats
* Run gofmt on unpack.go
Co-authored-by: James <jjohnsonjj1251@gmail.com>
-rw-r--r-- | starlark/unpack.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/starlark/unpack.go b/starlark/unpack.go index 86f9c4a..1493c85 100644 --- a/starlark/unpack.go +++ b/starlark/unpack.go @@ -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 { |