运行Hello Couchbase应用程序时出现紧急运行时错误[关闭]

Installed go SDK 1.6 following the instructions given here: https://docs.couchbase.com/go-sdk/current/start-using-sdk.html Created Hello Couchbase application as listed on the above page. While running the application, the program panics at the line :slight_smile: for rows.Next(&row) { and produces the following error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x12d66b2]

Go version prints the following: go version go1.12.9 darwin/amd64 macOS version 10.14.6

1个回答




一旦安装了SDK,您就可以运行此简单的代码段
,展示其某些功能。< / p>

为简洁起见,已省略错误检查。</ p>

https://docs.couchbase.com/go-sdk/current/start-using-sdk.html </ p>
</ blockquote>


在Go中,始终检查错误。 如果检查错误,则会发生什么错误?</ p>

错误</ p>

 紧急:运行时错误:无效的内存地址或nil指针取消引用\  n </ code> </ pre> 

通常表示错误已被忽略。</ p>
</ div>

展开原文

原文

Once you’ve installed the SDK you can run this simple code snippet showcasing some of its features.

Error checking has been omitted for brevity.

https://docs.couchbase.com/go-sdk/current/start-using-sdk.html


In Go, always check for errors. If you check for errors, what errors occur?

The error

panic: runtime error: invalid memory address or nil pointer dereference

often indicates that an error was ignored.

dse84825
dse84825 更改行:行,_:= bucket.ExecuteN1qlQuery(query,[] interface {} {“ African Swallows”})改为行,err:= bucket.ExecuteN1qlQuery(query,[] interface {} {“ African Swallows”}) 处理错误。 还将以下行中的存储桶名称更改为存储桶的实际名称:query:= gocb.NewN1qlQuery(“ SELECT * FROM bucketname WHERE $ 1 IN interest”)。 原始示例代码在这里:docs.couchbase.com/go-sdk/current/start-using-sdk.html
大约一年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问