草庐IT

site_user_address

全部标签

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

我目前正在使用Go的Soundcloud包装器,我想打印用户的关注者,但这是我第一次遇到指针问题。构建错误后panic:runtimeerror:invalidmemoryaddressornilpointerdereference[signal0xbcode=0x1addr=0x10pc=0xc9c26]代码packagemainimport("fmt""github.com/njasm/gosoundcloud")funcmain(){//callbackurlisoptional-nilinexamples,_:=gosoundcloud.NewSoundcloudApi("Cl

mongodb - mgo collection.Find(nil).All(&users) 不工作

我有下一个问题..我无法从我的mongo数据库(在docker容器中运行)中获取所有记录,这是我非常简单的代码:typeUserstruct{Emailstring`json:"email"bson:"email"`Passstring`json:"pass"bson:"pass"`}session:=dbConnect()collection:=session.DB("my_db").C("users")varusers[]Usererr:=collection.Find(nil).All(&users)iferr!=nil{log.Fatal("Mongocollectionfin

testing - echo c.Get ("user") 在测试环境中不起作用

我正在尝试测试基于echo框架/路由器构建的golangAPI。我有以下测试......funcTestLogout(t*testing.T){loadConfig()db:=stubDBs(t)Convey("Whenyoupostto/logout",t,func(){Convey("withavalidtoken,youshouldgetaasuccessmsgandbeloggedout",func(){e:=echo.New()e.Use(middleware.JWTWithConfig(middleware.JWTConfig{SigningKey:[]byte("secr

go - 是否有可能触发 "invalid memory address or nil pointer dereference"的错误?

我有一个偶尔会崩溃的应用程序:panic:运行时错误:无效的内存地址或零指针取消引用[信号SIGSEGV:分段违规代码=0x1地址=0x20pc=0x122e64a]跟踪一直导致返回语句,该语句返回一个结构和错误。新(“一些用于调试的文本:”+err.Error())该结构似乎没有任何可以取消引用指针的内容,但我重构了该函数,因此它使用了按引用传递并且不需要返回该函数;它只返回了errors.New()。panic还是发生了。我检查了函数并对其进行了更改,因此它只返回错误,没有错误。New()字符串加上err.Error()。现在我似乎不能再引起panic了……所以问题是:关于erro

sqlite - 运行时错误 : invalid memory address or nil pointer dereference when Querying

我一直在研究用于身份验证的API,在尝试将其部署到服务器时,我偶然发现了这个奇怪的错误。该代码在我的笔记本电脑上运行得非常好,但是当我尝试部署它时,出现了这个错误:PANIC:runtimeerror:invalidmemoryaddressornilpointerdereferencegoroutine21[running]:github.com/urfave/negroni.(*Recovery).ServeHTTP.func1(0x7f5771b811e8,0xc4200980e8,0xc42009a870,0xc420138800)/home/linux/go/src/gith

go - 程序在主程序 block 中发现错误后出现 panic 。 panic : runtime error: invalid memory address or nil pointer dereference

我是golang的新手。在定义位置后trycatch主block中的错误后,我的程序出现panic。我在某处读过,添加defer.close()可能会有所帮助,但编译器再次说你的结构中不存在这样的定义帮助我解决它。typeIPInfostruct{IPstringHostnamestringCitystringCountrystringLocstringOrgstringPostalstring}funcmain(){ip:=getLocalIpv4()location,err:=ForeignIP(ip)iferr!=nil{fmt.Println("errorbro")}fmt.P

go - 使用beego验证码: invalid memory address or nil pointer dereference

我想在Beego下使用captcha生成验证码。但是它有错误无效的内存地址或零指针取消引用。有谁知道如何解决这个问题?谢谢。RequestMethod:GETRequestURL:/accounts/forgotpasswordRemoteAddr:127.0.0.1StackC:/Go/src/runtime/asm_amd64.s:573C:/Go/src/runtime/panic.go:505C:/Go/src/text/template/exec.go:137C:/Go/src/runtime/asm_amd64.s:573C:/Go/src/runtime/panic.go

go - 获取变量\"$address\"不能是非输入类型\"String!\in go-graphql

我已经使用graphql-go库在go中成功设置了一个GraphQL服务器。但是,在进行查询时传递查询参数时,我似乎遇到了错误。所以我有一个名为emails的查询,它将address作为参数并查询数据库以返回与给定address关联的所有电子邮件的结果.当我直接传递address参数时,一切似乎都很完美,正如您从这张图片中看到的:但是,当我向它传递查询参数时,它似乎不起作用,如下所示:我不认为这两个语句应该给出相同的结果。然而,情况似乎并非如此。有人可以帮助我理解为什么会出现这些错误吗?这是我的代码packagemainimport("log""net/http""github.com

go - standard_init_linux.go :207: exec user process caused "no such file or directory" while trying to statically link c libs

我无法在go中对用c编写的实用程序进行docker化和使用。我已经在没有docker的情况下在本地运行了这个程序并且它有效我尝试像这样使用gccgogobuild-compilergccgo-gccgoflags-static-libgo但我得到了同样的错误调用C函数的序言如下所示:/*#cgoamd64x86LDFLAGS:-L.-lsomelib-lsomeotherlib#include#include#include"someheader.h"*/我的docker文件如下所示:FROMgolang:1.12ASbuildWORKDIR/go/src/appCOPY..ENVGO

go - xorm 示例不工作 : "runtime error: invalid memory address or nil pointer dereference"

基于this示例我试图编写一个程序,该程序将从数据库返回一些数据。不幸的是,根据运行时控制台输出,(或多或少)相同的程序结构会在此处导致内存错误err:=orm.Find(&sensorDataEntry)。我在这里错过了什么?示例和我的程序都有使用make()创建的slice,并在Find()方法中使用引用。有问题的代码:packagemainimport("fmt""net/http""time""github.com/gorilla/mux"_"github.com/lib/pq"//"database/sql""github.com/go-xorm/xorm")varorm*x