草庐IT

curl_error

全部标签

go - main func 上的 reviced channel error 但是 goroutine 中的 if reviced progrenn 没有错误

我通过goroutine将数据发送到channel。当我想在主函数中接收它时,在channel的最后一次接收时出现死锁,packagemainimport("time""fmt")funcsender(chchanstring){ch输出:printresult%schenlprintresult%szhangsprintresult%slisifatalerror:allgoroutinesareasleep-deadlock!goroutine1[chanreceive]:main.main()但是,如果我也在goroutine中替换接收到的进度,则没有错误orrced。有人可以帮

go - 库/pq : Runtime error when querying a database

我正在为我的Go后端设置一个PostgreSQL数据库,但是我在尝试读取一个表时遇到了这个错误:runtimeerror:invalidmemoryaddressornilpointerdereference/FwzFiles/go/src/runtime/panic.go:82(0x4423b0)panicmem:panic(memoryError)/FwzFiles/go/src/runtime/signal_unix.go:390(0x4421df)sigpanic:panicmem()/FwzFiles/go/src/database/sql/sql.go:1080(0x4e5

go - 我收到错误 fatal error : runtime: out of memory while downloading video using 'go-ipfs-api'

我使用go-ipfs-api从ipfs下载了一个大文件,web访问下载。我收到一个fatalerror:runtime:outofmemory.如何修改我的代码?funcmain(){http.HandleFunc("/",download)http.ListenAndServe(":8080",nil)}funcdownload(whttp.ResponseWriter,r*http.Request){client:=shell.NewShell("http://127.0.0.1:5001")fd,err:=client.Cat("QmTcj7SfRf4vnLnCqnxMT7kut

curl - net/http vs curl - 为什么在 curl 不超时的情况下超时?

我有一段代码检查http/s端点的状态和加载时间。然后我会为每个顶级页面检查1级href,以检查页面引用的所有内容是否也加载了200。(我查了50个顶级页面,每个顶级页面平均有8个链接)我通过一些goroutines(25)和WaitGroup检查顶级页面。对于1级页面,我尝试了另一个gouroutines+waitgroup,然后是一个直接的forloop(只是为了比较)。在这些1级页面上,我收到了很多“CLient.Timeoutexceededwhilewaitingheaders”错误。当我抓取这样一个url,并立即使用curl重试时,它会完美加载(带有curl)页眉超时的页面

go - 接口(interface)的结构嵌入, panic : runtime error

我正在尝试一个与接口(interface)的结构嵌入相关的示例//https://talks.golang.org/2014/go4java.slide#52//Structembeddingofinterfaces//https://play.golang.org/p/SYiZ7M1OEhUpackagemainimport("bytes""fmt""net")//net.ConnhasReadandWritetypeloopBackstruct{net.Connbufbytes.Buffer}func(c*loopBack)Read(b[]byte)(int,error){fmt.

string - 为什么 Error() 优先于 String()

我一直在寻找go的游览,但我不明白为什么会这样。当您有一个Stringer(String()string)时,fmt将使用该方法打印到控制台。就像https://tour.golang.org/methods/6中的建议一样但是,如果您添加Error()string,将调用此方法而不是String()string。packagemainimport"fmt"typePersonstruct{NamestringAgeint}func(p*Person)String()string{returnfmt.Sprintf("%v(%vyears)",p.Name,p.Age)}func(p*

go - curl http 服务器没问题,但浏览器不起作用

我刚开始接触Golang中的网络应用。这是作为起点的简单代码:packagemainimport("fmt""log""net/http")const(CONN_HOST="localhost"CONN_PORT="8080")funchelloWorld(whttp.ResponseWriter,r*http.Request){fmt.Fprintf(w,"HelloWorld!")}funcmain(){http.HandleFunc("/",helloWorld)err:=http.ListenAndServe(CONN_HOST+":"+CONN_PORT,nil)iferr!

go - 无法将错误转换为 go-sqlite3.Error

关闭。这个问题是notreproducibleorwascausedbytypos.它目前不接受答案。这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助future的读者。关闭3年前。Improvethisquestion我试图将Go中的错误转换为go-sqlite3.Error,但它总是失败。上图代表我的调试窗口的快照,它显示错误是go-sqlite3.Error类型我正在使用下面的代码进行类型转换。import("github.com/mattn/go-sqlite3")iferr!=nil{ifsqlite3E

go - 意外情况,编译go时expecting expression error

当我编译下面的代码时,它会生成*语法错误:unexpectedcase,expectingexpression*在*caseworkerAddr=行我不知道为什么会这样,因为我只想通过任一channel设置workerAddr。任何建议将不胜感激。fori:=0;i 最佳答案 发生这种情况是因为您在应该编写select的时候编写了Select。Go关键字都不是大写的,因此当编译器看到大写的单词时,它会立即知道它不是表达式,因此会出现语法错误。 关于go-意外情况,编译go时expecti

arrays - For 循环导致 panic : runtime error due to nil map or slice

嘿,我正在尝试为我的程序创建一个简单的标量向量。我从一个简单的变量开始,然后递增它以使其成为32x1大小的向量矩阵。varx[]intfori:=0;i很简单,但是在尝试编译时出现此错误。panic:runtimeerror:indexoutofrangegoroutine1[running]:main.main()/Users/jeanmac/go/src/matrices/main.go:69+0x7dProcessfinishedwithexitcode2不知道为什么。仅供引用,第69行指的是x[i]=i+1。尝试分配x[i]时,我收到以下警告。报告可能导致运行时panic的ni