草庐IT

依赖查找

全部标签

mongodb - 使用 MongoDB 和 Golang 通过聚合和查找查找重复项

我需要使用MongoDB和Golang进行聚合和查找来查找重复项。这是我的Event结构。//EventdescribesthemodelofanEventtypeEventstruct{IDstring`bson:"_id"json:"_id"valid:"alphanum,printableascii"`OldIDstring`bson:"old_id"json:"old_id"valid:"alphanum,printableascii"`ParentIDstring`bson:"_parent_id"json:"_parent_id"valid:"alphanum,printa

docker - 为 golang 的 dockerfile 查找路径时出错

我正在尝试用我的golang项目构建docker镜像我使用以下内容#buildstageFROMgolang:alpineasbuilderWORKDIR/go/src/appCOPY..RUNCGO_ENABLED=0GOOS=linuxgobuild-a-installsuffixcgo-ldflags'-extldflags"-static"'-omain.RUNapkadd--no-cachegit#finalstageFROMalpine:latestRUNapk--no-cacheaddca-certificatesCOPY--from=builder/go/bin/app

go - 设置go dep后依赖出现问题

我的项目位于$GOPATH/src/smp-cloudupload我可以毫无错误地运行depinit。之后我不能再编译这个项目了。错误之一:main/scs/scsApiGateway.go:5:2:cannotfindpackage"_/home/dev/go/src/smp-cloudupload/vendor/github.com/dgrijalva/jwt-go"inanyof:/usr/lib/go-1.10/src/_/home/dev/go/src/smp-cloudupload/vendor/github.com/dgrijalva/jwt-go(from$GOROOT

go - 如何在 colly 中通过 id 或 class 查找一个 html 元素或一组 html 元素?

我正在使用colly用于抓取网站。在OnHTML回调中:packagemainimport("fmt""github.com/gocolly/colly")funcmain(){//Instantiatedefaultcollectorc:=colly.NewCollector()//Oneveryaelementwhichhashrefattributecallcallbackc.OnHTML("h3",func(e*colly.HTMLElement){link:=e.Text//Printlinkfmt.Printf("Linkfound:%q->%s\n",e.Text,lin

go - 嵌套依赖注入(inject)在 golang 中是否可以接受?

嵌套依赖注入(inject)有什么问题吗?例如:typeParentServicestruct{db*sql.DB}typeUsefulChildStructstruct{attrAintattrBintdb*sql.Db}funcNewParent(db*sql.DB)*ParentService{return&ParentService{db:db}}func(p*ParentService)NewChild()*UsefulChildStruct{return&UsefulChildStruct{db:p.db}}func(c*UsefulChildStruct)DoSometh

unit-testing - 以 http 作为包装函数的依赖项的单元测试

我有以下函数,在@poy的帮助下,我能够为它创建模拟以便对其进行单元测试。现在的问题是我有包装函数也需要测试这是原始函数,已经过测试funchttpReq(cc[]string,methodstring,urlstring)([]byte,error){httpClient:=http.Client{}req,err:=http.NewRequest(method,url,nil)iferr!=nil{returnnil,errors.Wrap(err,"failedtoexecutehttprequest")}//Herewearepassinguserandpasswordreq.

走线,连接依赖项

我正在使用Googlewire在我的一个Go项目中连接依赖项。到目前为止,所有依赖项都已成功连接。我有以下容器:typeContainerstruct{Loggerlogger.StructuredLoggerIDGeneratoridgenerator.IDGeneratorArangoarangodb.Arango}这里StructuredLogger、IDGenerator和Arango是接口(interface)。容器集定义如下:varmockContainerSet=wire.NewSet(Container{},ResolveStructuredLogger,Resolve

go mod vendors 旧版本的依赖

我升级到go1.11并且正在尝试使用go模块。我克隆了一个项目并运行gobuild,它创建了一个包含我所有依赖项的go.mod和go.sum文件。现在我想提供文件,所以我运行命令gomodvendor不幸的是,modvendor使用旧版本的go-bindata.我的项目无法构建,因为函数调用不存在。查看vendoredgo-bindata的源代码,我可以看到它与go-bindata项目的master分支中可用的不同。在我的go.mod文件中有这个:github.com/jteeuwen/go-bindatav3.0.7+incompatible在我的go.sum文件中,有这个:gith

go - 将 Caddy 导入 go 项目依赖项失败

我想将Caddy导入到一个go项目中,但我似乎无法提出最基本的示例。我尝试使用dep或gomod拉取依赖项,但都失败了。dep初始化Noversionsofgolang.org/x/textmetconstraints:v0.3.0:unabletoupdatecheckedoutversion::commandfailed:[gitcheckoutf21a4dfb5e38f5895301dc265a8def02365cc3d0]:exitstatus128v0.2.0:unabletoupdatecheckedoutversion::commandfailed:[gitcheckou

regex - 使用 Regex golang 查找所有字符串匹配项

我正在尝试返回一个数组或slice,其中包含特定正则表达式与字符串的所有匹配项。字符串是:{city},{state}{zip}我想返回一个数组,其中包含大括号之间的所有字符串匹配项。我试过使用regexp包来完成这个但无法弄清楚如何返回我正在寻找的东西。这是我当前的代码:r:=regexp.MustCompile("/({[^}]*})/")matches:=r.FindAllString("{city},{state}{zip}",-1)但是,无论我尝试什么,它每次都返回一个空slice。 最佳答案 首先,您不需要正则表达式分隔