我正在尝试查询一个测试键空间,例如:
package main
import "fmt"
import _ "github.com/gocql/gocql"
var (
gocql string
)
func main() {
// connect to the cluster
cluster := gocql.NewCluster("127.0.0.1")
cluster.Keyspace = "dbaccess"
session, _ := cluster.CreateSession()
defer session.Close()
if err := session.Query("SELECT name, age FROM people WHERE name='doug'").Scan(&name, &age); err != nil {
log.Fatal(err)
}
fmt.Println(name, age)
}
但我收到如下错误:
12: gocql.NewCluster undefined (type string has no field or method NewCluster)
这是否意味着它试图指向 gocql/gocql 文件夹中的方法但找不到它,或者导入内容的语法是否错误?