草庐IT

Content_for

全部标签

go - 限制 VS Code for Go 仅下载 v 1.11 的包

我正在使用VisualStudioCode1.33.1版作为我们的Go应用程序的IDE。我们想为我们的应用程序使用Go版本1.11。但是看起来我们正在使用的一个或多个依赖项已经为Go1.12下载了一个包。现在,VSCode无法构建应用程序并出现以下错误:gobuildgolang.org/x/sys/unix:modulerequiresGo1.12gobuildgithub.com/pelletier/go-toml:modulerequiresGo1.12go[1,1]我尝试重新安装Go1.11,删除有问题的软件包并让它重新安装。无论我何时尝试构建VSCode,下载1.12版本都无

go - 未定义 : SQLiteConn when trying to build go app for armv7

我必须为UbuntuARM-v7编译一个Go服务当我编译它时GOARCH=armGOARM=7gobuild-v-orelease/edge_to_bc-ldflags'-s-w-extldflags"-static"'./...我得到:gitlab.com/company/edge_to_bc/vendor/github.com/hyperledger/fabric/bccsp/pkcs11#gitlab.com/company/edge_to_bc/vendor/github.com/hyperledger/fabric/bccsp/pkcs11vendor/github.com/

go - 如何修复 VS Code 错误 : "Not able to determine import path of current package by using cwd" for Go project

我正在学习教程,我想我可能错过了一些东西。我有一个Go项目位于:/Users/just_me/development/testing/golang/example_server内容是:main.gopackagemainimport"fmt"funcmain(){fmt.Println("hiworld")}我有一个~/go目录。goenv显示:GOPATH="/Users/just_me/go"GOROOT="/usr/local/Cellar/go/1.12.9/libexec"我在VSCode中安装了建议的包。当我保存我的main.go时,我得到:Notabletodetermi

go - 如何在 GoLang 的命令行上取消设置标志 Visited for Tests

我正在尝试运行每次使用不同参数多次调用同一函数的测试。这是一个接受不同命令行标志的应用程序。如果未提供命令行标志,则使用默认值。flagset=make(map[string]bool)flagset["flag1"]=falseflagset["flag2"]=falseflagset["flag3"]=falseflagset["flag4"]=falsefuncLoadCommandLineArguments(args[]string)error{err:=flag.CommandLine.Parse(args)/*Doerrorhandling*/flag.Visit(func

for-loop - GO:使用for循环添加到 map

关闭。这个问题需要detailsorclarity.它目前不接受答案。想改进这个问题吗?通过editingthispost添加细节并澄清问题.关闭8年前。Improvethisquestion我一直在尝试使用golang中的for循环添加到map,但我一直无法这样做。谁能举一个简单的例子说明如何做到这一点?谢谢!

mongodb - chrome 和 safari 不会在设置了 Content-Length 的 go 服务器提供的 html 模板中呈现图像

我在GridFS上存储了一些图像,并使用简单的Go网络服务器提供资源。funcGetFile(whttp.ResponseWriter,r*http.Request){fileObjectId:=r.URL.Path[len("/file/"):]gfs:=db.GridFS("fs")file,err:=gfs.OpenId(bson.ObjectIdHex(fileObjectId))iferr!=nil{panic("filenotfound")}w.Header().Set("Content-Length",strconv.FormatInt(file.Size(),10))w

go - Youtube Content ID API 总是返回 Not Found

我的帐户已连接到CMS,但我在API库中看不到YoutubeContentID。但是,我在启用的API中看到了它!!(它出现在我尝试YoutubeContentIDAPI引用文档中的“使用OAuth2.0授权请求”之后)。我可以在引用文档中测试API,它会显示来self的CMS的数据。但是当我从我的程序中调用API时,响应总是这样的:{"error":{"errors":[{"domain":"global","reason":"notFound","message":"NotFound"}],"code":404,"message":"NotFound"}}这是我使用Go实现的:fu

go - 结构初始化的嵌套数组 : how to do if constructors for both struct are available?

刚接触golang。我有两种结构类型(称为Inner和Outer),并且每个结构类型都有我想使用的构造函数。外部结构“有一个”内部结构的二维数组。如何在外部结构的构造函数中使用内部类型的构造函数来初始化内部数组?typeInnerstruct{valint}funcnewInner(valint)*Inner{i:=new(Inner)i.val=valreturni}typeOuterstruct{members[][]Innerrowintcolint}funcnewOuter(rowint,colint)*Outer{o:=new(Outer)o.row=rowo.col=col

高语 : "No common algorithm for key exchange" error

我是GoLang的新手,我正在尝试使用go连接到远程服务器。但是我不断收到以下错误Failedtodial:ssh:handshakefailed:ssh:nocommonalgorithmforkeyexchange;clientoffered:[curve2****-sh****@libssh.org****-sha*-nis****ecdh-sha2-nistp384ecdh-sha2-nistp****diffie-hellman-group14-sha1diffie-hellman-group1-sha1],serveroffered:[diffie-hellman-grou

for-loop - golang 初始化后得到空 slice

我有3个结构:Queue、Config、TaskertypeQueuestruct{NamestringConcurrentintConnections[]*redis.Client}typeConfigstruct{Queues[]QueueRedisAddrstringRedisDBint}typeTaskerstruct{ConfigConfig}问题发生在这个方法中,我在for循环中初始化了queue.Connections,但是我在for循环之外得到了零长度的queue.Connectionsfunc(t*Tasker)StartListening(){forj:=0;j这是