草庐IT

module_has_competence

全部标签

go - 构建命令行参数 : cannot load local package: cannot find module providing package

我无法使用gomod加载本地包。我有单独的go.mod文件用于repoA和repoB。我在任何地方都找不到解决方案。操作系统是windows。$>goversiongoversiongo1.12.7windows/amd64当我从repoA运行主文件时,我有两个带有存储库的模块。它将尝试查找repoB的模块/包,然后抛出一个错误提示cannotfindmoduleprovidingpackage我的repo结构:-����repoA�����proto������system�����sauth�����shandle�����smodel�����sresponse����repoB

go - 无法在 GORM 中设置 has-many 关联

我正在尝试在User和PredictionsBag之间建立关联。我的问题是,如果我使用GORM的假定名称来引用对象,一切正常,但我想稍微更改一下名称。typeUserstruct{gorm.Model//We’lltrynotusingusernamesfornowEmailstring`gorm:"notnull;unique_index"`Passwordstring`gorm:"-"`PasswordHashstring`gorm:"notnull"`Rememberstring`gorm:"-"`//Auser’sremembertoken.RememberHashstring

go - 使用 GO111MODULE 安装 buffalo 导致 go get : error loading module requirements

这个问题在这里已经有了答案:GO111MODULE=on(errorloadingmodulerequirements)(1个回答)关闭3年前。我在尝试安装buffalo时遇到错误。我在goversiongo1.12.7linux/amd64上使用干净的GOPATH进行了测试,其中没有任何内容。GO111MODULE设置为on。我尝试使用网站上给出的命令安装buffalo:goget-u-vgithub.com/gobuffalo/buffalo/buffalo执行命令导致返回代码1,详细输出末尾的错误消息似乎是goget:errorloadingmodulerequirements。

由于 : "go directory outside available modules",Docker 构建失败

我在构建我的go服务的Docker镜像时遇到问题(请参阅最后的错误消息)。我的服务代码结构如下:cmd-duc-adobepkg-adobe-common.gitignoreDockerfilego.modgo.sum这是我的Dockerfile:#buildimageFROMgolang:1.12-alpineasbuilderRUNapkupdate&&apkadd--no-cachegitca-certificates&&update-ca-certificatesWORKDIR/app#firstdownloaddependenciessothatwecanutilizethe

go - 如何修复 gomod : `github.com/stretchrcom/testify@v1.4.0: parsing go.mod: unexpected module path "github. com/strethr/testify"`

当我执行gomodtidy时。我收到以下错误:go:github.com/stretchrcom/testify@v1.4.0:parsinggo.mod:unexpectedmodulepath"github.com/stretchr/testify" 最佳答案 此错误是由于在将testify移动到github.com/stretchr/testify之前引用testify的包造成的。解决方案是在您的go.mod中添加以下行:替换github.com/stretchrcom/testifyv1.4.0=>github.com/st

mongodb - Go 和 MongoDb 错误 : has no field or method

我是Golang的新手。在尝试从MongoDb查询结果中提取password时,出现以下错误:"./1.go:73:results.passwordundefined(type[]Personhasnofieldormethodpassword)"错误是由代码中的倒数第二行引起的。如何分离查询结果?代码:packagemainimport("fmt""html/template""log""net/http""reflect""gopkg.in/mgo.v2/bson""gopkg.in/mgo.v2")typeloginstruct{UserNamestringPasswordstr

go - undefined <type float32 has no field or method sum> 错误。如何解决?

这是我的程序。当我运行它时,它给出了以下错误-a.sumundefined(typefloat32hasnofieldormethodsum)packagemainimport("fmt")typeCalculationinterface{operation(input[]float32)}typeAdditionstruct{sumfloat32}func(aAddition)operation(input[]float32){a.sum=input[0]for_,a:=rangeinput[1:]{a.sum+=a}fmt.Println("Sum:",a.sum)}funcmai

Golang (v1.8) - 错误 : type *mux. Route has no field or method Method

我有一个配备了gorilla工具包的go/golang应用程序。我正在尝试使用gorilla/mux包进行路由。我的路线和错误信息如下。有什么指点吗?路线`r:=mux.NewRouter()r.HandleFunc("/",landing)r.HandleFunc("/contact",contact)r.HandleFunc("/faq",faq)r.HandleFunc("/register",accountsC.New).Method("GET")r.HandleFunc("/register",accountsC.Create).Method("POST")http.List

Go Modules - 目录和包的命名约定

我明白了GoModules仍然是一个实验性的选择加入功能,也许正因为如此,我找不到关于如何命名目录和package的明确指导。在这些PackagenamesinGoBlog发布和PackagenameinEffectiveGo,他们说目录应该与包名称相匹配——但我不确定GoModules是否会遵循相同的模式。如果我想在packagebusiness中将我的业务逻辑与许多文件捆绑在一起,创建子目录validators/并保持相同的包名称package是否合理业务?someDir├──business│  ├──businessA.go//packagebusiness│  ├──busi

使用提交哈希时 Go Modules "unknown revision"错误

我需要拉this提交到我的go项目中。我已经尝试了多个版本的go.mod:...require(github.com/libp2p/go-libp2p-core@v0.0.7-0.20190626134135-aca080dccfc2//and...github.com/libp2p/go-libp2p-corev0.0.0-20190626-aca080dccfc2c9933df66baafe6cf9cc4f429825)...两者在运行$gobuild时都会导致错误:$gobuildgo:findinggithub.com/libp2p/go-libp2p-corev0.0.0-2