# Float64 not supported

**URL:** <https://discuss.aerospike.com/t/float64-not-supported/1707>\
**Category:** Go Client\
**Created:** [August 26, 2015, 2:47pm UTC](https://discuss.aerospike.com/t/float64-not-supported/1707 "2015-08-26T14:47:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![no1youknowz](https://avatars.discourse-cdn.com/v4/letter/n/b782af/32.png) [@no1youknowz](https://discuss.aerospike.com/u/no1youknowz)\
**Post date:** [August 26, 2015, 2:47pm UTC](https://discuss.aerospike.com/t/float64-not-supported/1707/1 "2015-08-26T14:47:18Z")

</div>

I have a payload generated from PHP and sent to GO which gets imported to Aerospike.

Here is an example:

PHP:

```
$p_data['tracking_lander_url_string_' . $nugget['lander_id']] = array(
	'chn_viewport' => (string)$nugget['options']['change_viewport'],
	'viewport_text' => $nugget['options']['change_viewport_text'],
	'spintax' => array(),
	'last_update' => date("Y-m-d H:i:s")
);

```

So I am casting an integer as a string. I have to do this as I get a panic with go:

```
map[chn_viewport:0 viewport_text:,,, spintax:[] last_update:2015-08-26 10:43:46]
panic: Value type 'float64' not supported

```

Why is the go code in value.go failing to detect as an int64?

Thanks

---

<div class="post-metadata">

**Author:** ![Khosrow\_Afroozeh](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@Khosrow\_Afroozeh](https://discuss.aerospike.com/u/Khosrow_Afroozeh)\
**Post date:** [August 26, 2015, 3:12pm UTC](https://discuss.aerospike.com/t/float64-not-supported/1707/2 "2015-08-26T15:12:42Z")

</div>

Do you encounter this while reading from the database, or writing?

Can you provide a small code snippet to show me what you are trying to do?

---

<div class="post-metadata">

**Author:** ![no1youknowz](https://avatars.discourse-cdn.com/v4/letter/n/b782af/32.png) [@no1youknowz](https://discuss.aerospike.com/u/no1youknowz)\
**Post date:** [August 26, 2015, 3:29pm UTC](https://discuss.aerospike.com/t/float64-not-supported/1707/3 "2015-08-26T15:29:38Z")

</div>

I’m writing to the database.

Go receives json as the payload and then processes it into aerospike.

The code is pretty trivial:

```
type Record struct {
	Bin string `json:"bin"`
	Table string `json:"table"`
	DataRaw map[string]interface{} `json:"data"`
}

func process(client *as.Client, payload string) {
	var jsonData Record
	json.Unmarshal([]byte(payload), &jsonData)

	for _key := range jsonData.DataRaw {
		i := jsonData.DataRaw[_key]
		m := i.(map[string]interface{})

		key, _ := as.NewKey(jsonData.Bin, jsonData.Table, _key)
		err := client.Put(nil, key, m)

		if err != nil {
			fmt.Println(_key)
			fmt.Println(m)

			panic(err)
		}
	}
}

```

---

<div class="post-metadata">

**Author:** ![Khosrow\_Afroozeh](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@Khosrow\_Afroozeh](https://discuss.aerospike.com/u/Khosrow_Afroozeh)\
**Post date:** [August 26, 2015, 3:57pm UTC](https://discuss.aerospike.com/t/float64-not-supported/1707/4 "2015-08-26T15:57:22Z")

</div>

float32 and float64 can be used in maps and arrays (there are tests in client\_test.go regarding that)

I assume you are passing a direct float value to Put. The code you’ve posted runs just fine on my system.

Are you sure this is the place you are getting your panic?

---

<div class="post-metadata">

**Author:** ![no1youknowz](https://avatars.discourse-cdn.com/v4/letter/n/b782af/32.png) [@no1youknowz](https://discuss.aerospike.com/u/no1youknowz)\
**Post date:** [August 26, 2015, 4:13pm UTC](https://discuss.aerospike.com/t/float64-not-supported/1707/5 "2015-08-26T16:13:30Z")

</div>

I’m passing a map to Put. As you can see, I’m just converting the interface to a map.

I don’t know if in the conversion it will define the types correctly. The payload I am generating at php is HUGE. There is no way I am going to loop through everything sub-object and define it. It’s too dynamic in nature.

This is the place for the panic, because if I remove the (string) cast at php for the integer, I get the same panic.

Also:

I only panic when the map is like this:

```
{ "foo" : 0, "a" : "a", "b" : "b", "c" : "c" }

```

This does not panic:

```
{ "bar" : {"foo" : 0, "a" : "a", "b" : "b", "c" : "c" } }

```

---

<div class="post-metadata">

**Author:** ![Khosrow\_Afroozeh](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@Khosrow\_Afroozeh](https://discuss.aerospike.com/u/Khosrow_Afroozeh)\
**Post date:** [August 27, 2015, 3:20pm UTC](https://discuss.aerospike.com/t/float64-not-supported/1707/6 "2015-08-27T15:20:05Z")

</div>

Your maps work without an error. Here’s another example with explicit float values which also works perfectly well:

```nohighlight
package main

import (
    "flag"
    "fmt"
    "log"

    as "github.com/aerospike/aerospike-client-go"
)

var host = flag.String("h", "127.0.0.1", "host")
var port = flag.Int("p", 3000, "port")
var user = flag.String("U", "", "User.")
var password = flag.String("P", "", "Password.")
var clientPolicy *as.ClientPolicy

func main() {
    flag.Parse()
    clientPolicy = as.NewClientPolicy()
    if *user != "" {
        clientPolicy.User = *user
        clientPolicy.Password = *password
    }

    client, err := as.NewClientWithPolicyAndHost(clientPolicy, as.NewHost(*host, *port))
    if err != nil {
        log.Fatal(err)
    }
    defer client.Close()

    // m := map[string]interface{}{"foo": 0, "a": "a", "b": "b", "c": "c"}
    // m := map[string]interface{}{"bar": map[string]interface{}{"foo": 0, "a": "a", "b": "b", "c": "c"}}
    m := map[string]interface{}{"bar": map[string]interface{}{"foo": float32(0.11), "foo2": float64(0.11), "a": "a", "b": "b", "c": "c"}}

    key, _ := as.NewKey("test", "test", 1)
    err = client.Put(nil, key, m)
    if err != nil {
        fmt.Println(m)

        panic(err)
    }

    rec, err := client.Get(nil, key)
    if err != nil {
        panic(err)
    }

    fmt.Printf("map is: %#v\n", rec.Bins)

    fmt.Println("Success...")
}

```

---

<div class="post-metadata">

**Author:** ![Khosrow\_Afroozeh](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@Khosrow\_Afroozeh](https://discuss.aerospike.com/u/Khosrow_Afroozeh)\
**Post date:** [August 27, 2015, 3:35pm UTC](https://discuss.aerospike.com/t/float64-not-supported/1707/7 "2015-08-27T15:35:34Z")

</div>

Now I see, you are iterating over the `Record.DataRaw`, and assume you are getting a `map[string]map[string]interface{}`.

When you pass `{ "foo" : 0, "a" : "a", "b" : "b", "c" : "c" }` as payload, it will be decoded as `map[string]interface{}`, and will panic when you try to cast elements like `0` or `"c"` into `map[string]interface{}`.

---

<div class="post-metadata">

**Author:** ![no1youknowz](https://avatars.discourse-cdn.com/v4/letter/n/b782af/32.png) [@no1youknowz](https://discuss.aerospike.com/u/no1youknowz)\
**Post date:** [September 1, 2015, 2:00am UTC](https://discuss.aerospike.com/t/float64-not-supported/1707/8 "2015-09-01T02:00:56Z")

</div>

Thanks for the explanation. Now I understand.

I’ll just keep my code as normal. I’ll cast things as a string, as I’m getting it from PHP.
