草庐IT

invalid-name

全部标签

mongodb - 当我尝试调用 API 时,本地服务器返回 "http: panic serving [::1]:52781: runtime error: invalid memory address or nil pointer dereference"

关闭。这个问题需要debuggingdetails.它目前不接受答案。编辑问题以包含desiredbehavior,aspecificproblemorerror,andtheshortestcodenecessarytoreproducetheproblem.这将有助于其他人回答问题。关闭3年前。Improvethisquestion我按照指南在这里编写了mongodbAPI:https://www.thepolyglotdeveloper.com/2019/02/developing-restful-api-golang-mongodb-nosql-database/指南的代码运行

regex - Golang regex lookarround 不支持错误解析 regexp : invalid or unsupported Perl syntax: `(?!`

这个问题在这里已经有了答案:Howtoconvertregexpfromlookahead(1个回答)Usingpositive-lookahead(?=regex)withre2(2个答案)HowtosimulatenegativelookbehindinGo(2个答案)Negativelook-aheadinGoregularexpressions(3个答案)Goregex,NegativeLookAheadalternative(1个回答)关闭3年前。我有一个正则表达式来检测CSS中的绝对路径,它可以使用javascript,但在GOLANG中不行:这是我的正则表达式:url\(

go - 如何在 go 中使用 os.Name()?

我正在尝试使用:https://golang.org/src/os/file.go?s=1472:1577#L35通过导入“os”包然后运行f,err:=os.Open("/tmp/dat3")check(err)name:=os.Name(f)我得到./main.go:29:undefined:os.Name为什么?我究竟做错了什么。(我当然知道我有打开文件的名称-但我很好奇为什么,我无法调用该函数) 最佳答案 因为Name是定义在File结构上的特殊函数(method)。意味着它采用File类型作为接收器,并且可以使用接收器实例

http - Golang 中的 "Invalid memory address"使用 ioutil.ReadAll()

我目前正在学习Golang(到目前为止我很喜欢它)。但不幸的是,我已经被困了几个小时,而且我似乎没有在Google上找到任何解决我的问题的方法。所以这是我的问题。我有这段代码(来自教程):funcmain(){varsSitemapIndexresp,_:=http.Get("https://www.washingtonpost.com/news-sitemaps/index.xml")bytes,_:=ioutil.ReadAll(resp.Body)resp.Body.Close()xml.Unmarshal(bytes,&s)for_,Location:=ranges.Locat

go - 语法错误 : unexpected name, 需要分号或换行符

我不明白为什么我的代码有语法错误。packagemainimport("fmt""os/exec""time")funcping(curl_outstring)endtimeint64{try_curl:=exec.Command("curl","localhost:8500/v1/catalog/nodes")try_curl_out:=try_curl.Output()fortry_curl_out==curl_out{try_curl:=exec.Command("curl","localhost:8500/v1/catalog/nodes")try_curl_out:=try_

golang 无法写入文本文件 : the handle is invalid

大家好,我很抱歉这么快又问了一个问题,但最近Go似乎是一回事。我有一个可用的网页抓取工具(感谢大家的帮助),它可以从这个wiki页面抓取我想要的所有信息:http://monsterhunter.wikia.com/wiki/MH4U:_Item_List然后它会显示我想要的一切,没有任何问题。但是,当我去写入一个.txt文件时,我收到一条错误消息:“0writemh4u.txt:Thehandleisinvalid”这是我目前的引用代码:packagemainimport("fmt""log""github.com/PuerkitoBio/goquery""os""io")funcm

go - -bash : set: -g: invalid option when I setting GOPATH

当我设置GOPATH时,使用:set-gxGOPATH/usr/local/Cellar/go/1.8.1我遇到了这个问题:-bash:set:-g:invalidoptionset:usage:set[--abefhkmnptuvxBCHP][-ooption][arg...] 最佳答案 bash命令set不支持g选项。此外,此命令不用于一起设置环境变量-您的代码段可能适用于不同的shell(fishshell?)。在bash中,按照建议使用export:exportGOPATH/usr/local/Cellar/go/1.8.1

go - panic : runtime error: invalid memory address or nil pointer dereference when running Blockchainr

我运行blockchain并获得以下终端输出:17:39:572015-06-16[INF]loadingdbleveldbpanic:runtimeerror:invalidmemoryaddressornilpointerdereferencepanic:runtimeerror:invalidmemoryaddressornilpointerdereference[signal0xbcode=0x1addr=0x0pc=0x402cb63]goroutine1[running]:main.search(0x4911ef8,0xc20806e2d0,0x0,0x0,0x4911ef

java - 如何触发 java 应用程序(来自 Google GO/golang sub_process 的 java -jar <app name>

我正在尝试将java命令行应用程序作为golang的子进程触发。由于某种原因它失败了,实际上当我从GO启动它时我没有得到javaAPP界面。它等待几秒钟并以错误代码“无法连接...”终止这是我尝试使用的代码:packagemainimport("fmt""os/exec")funcmain(){start_java_app_test()}funcstart_java_app_test(){cmd_prep:="java-Xmx2g-jartest_app.jar"cmd_output,err:=exec.Command("bash","-c",cmd_prep).Output()ife

opengl - 为什么 glDrawArrays 因 GL_INVALID_OPERATION 而失败?

我正在使用OpenGL绘制一个矩形,我正在使用golang进行绘制。我暂时不使用红、绿、蓝参数。varvertices=[]float64{-1.0,-1.0,0.0,//V1-bottomleft-1.0,1.0,0.0,//V2-topleft1.0,-1.0,0.0,//V3-bottomright1.0,1.0,0.0,//V4-topright}funcDisplayWrite(red[]byte,green[]byte,blue[]byte){constGL_TRUE=1constGL_FALSE=0constGL_FLOAT=0x1406constGL_VERTEX_AR