Aerospike Golang 客户端 putObject 方法让我感到恐慌:反映:在地图值上调用 reflect.Value.Elem

Aerospike Golang client putObject method gives me panic: reflect: call of reflect.Value.Elem on map Value

我正在尝试将 MongoDB 的结果保存到 AeroSpike 中。我正在为 Mongodb 使用 MGO 客户端。代码如下:

package main

import (
    "log"
    "flag"
    "fmt"
    ///"reflect"
    "gopkg.in/mgo.v2"
    "gopkg.in/mgo.v2/bson"
    as "github.com/aerospike/aerospike-client-go"
   /// "encoding/json"
)


/*
Iterating through the results
 */
 results := make(map[string]interface{})
 iter := c.Find(nil).Iter()
for iter.Next(&results) {

    tmp := make(map[string]interface{})
    b, _ := bson.Marshal(results)
    bson.Unmarshal(b, &tmp)
        log.Println("func (interface, interface):",  tmp["_id"])
/*
Aerospike Key
 */
        key, err := as.NewKey(*Namespace, *Set, "LIST")
if err != nil {
    log.Fatal(err)
}

/*
Saving to aerospike
 */
client.PutObject(WritePolicy, key, tmp)

}
if err := iter.Close(); err != nil {
   fmt.Println(err)
}

我从 Aerospike 收到以下错误:

panic: reflect: call of reflect.Value.Elem on map Value

goroutine 1 [running]:
reflect.Value.Elem(0x24dd40, 0xc20803b020, 0x15, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.4.2/libexec/src/reflect/value.go:703 +0x1d5
github.com/aerospike/aerospike-client-go.marshal(0x24dd40, 0xc20803b020, 0xc208052101, 0x0, 0x0, 0x0)
    /Users/milos/Downloads/golang/src/github.com/aerospike/aerospike-client-go/marshal.go:143 +0xa1

我已经求助于 google,但运气不佳。

为了完整性测试,我有 运行 以下内容以查看结构是否保存到 AeroSpike 中并且确实保存了。

 type OBJECT struct {
    Price  int
    DBName string
}

obj := &OBJECT{198, "Jack Shaftoe and Company"}
 errr := client.PutObject(WritePolicy, key, obj)
if errr != nil {
    log.Fatal(errr)
}
}
if err := iter.Close(); err != nil {
   fmt.Println(err)
}

您正在尝试将 map 保存到 aerospike 中,而不是 struct

我认为最好的选择是将地图封装在一个结构中。