Go 混淆指针和值参数无关性

Go 混淆指针和值参数无关性,go,neo4j,Go,Neo4j,我正在用Go编写一个web应用程序,并使用Neo4j数据库存储数据。作为neo4japi,我选择 但是,请看下面的代码片段 db, _ := neoism.Connect("http://localhost:7474/db/data") // Create a node with a Cypher quer // Issue a query // res1 := []struct { A string `json:"n.email"` }{} cq1 := neoism.CypherQu

我正在用Go编写一个web应用程序,并使用Neo4j数据库存储数据。作为neo4japi,我选择

但是,请看下面的代码片段

db, _ := neoism.Connect("http://localhost:7474/db/data")
// Create a node with a Cypher quer
// Issue a query
//
res1 := []struct {
    A string `json:"n.email"`
}{}
cq1 := neoism.CypherQuery{
    //Use backticks for long statements - Cypher is whitespace indifferent
    Statement: `
        MATCH (n:Account {email: {email}})
        RETURN n.email
    `,
    Parameters: neoism.Props{"email": "hans@ueli.com"},
    Result:     &res1,
}
db.Cypher(&cq1)
fmt.Println(res1)
我在这里查询来自节点帐户的数据并得到一个结果返回,这里一切正常。 第二个代码几乎相同,但我在这里直接创建了一个指针片(变量res2)

// Validate, if email already available in db
res2 := []*struct {
    A string `json:"n.email"`
}{}
cq := &neoism.CypherQuery{
    Statement: `
        MATCH (n:Account {email: {email}})
        RETURN n.email
    `,
    Parameters: neoism.Props{"email": "hans@ueli.com"},
    Result:     res2,
}
db.Cypher(cq)
fmt.Println(res2)
它们之间的区别是,我通过第一个样本得到了一个结果,但第二个样本没有。
结果:


这里的指针res2有什么问题?

来自neoism文档:

结果必须是指向结构片的指针-例如&[]someStruct{}

没有关于结构指针的切片的说明,因此我假设您的切片是空的,因为函数不需要指针,所以它无法在切片中放入任何内容

我在给
sqlx.Query
错误类型的切片时遇到了相同的行为。缺少错误在第一次出现时是相当令人沮丧的,但它很快就变成了一种反射

[{hans@ueli.com}]
[]