[英]Go Mod Private Repo import path (cannot find module)
I have this private GIT structure 我有这个私人的GIT结构
github.com/my-company/project/webservices/service1
github.com/my-company/project/packages/stringslices
In the main() of the service1 package: 在service1包的main()中:
package main
import (
slice "github.com/my-company/project/packages/stringslices"
)
func main() {
data := []string{"a","b","c"}
slice.SomeFunc(data)
}
when I try to build I get this error: 当我尝试构建时,出现此错误:
build github.com/my-company/project/webservices/service1: cannot find module for path github.com/my-company/project/packages/stringslices 构建github.com/my-company/project/webservices/service1:找不到路径github.com/my-company/project/packages/stringslices的模块
My project is outside the GOPATH Each project has a go.mod file with it 我的项目在GOPATH之外每个项目都有一个go.mod文件
How do I resolve this? 我该如何解决? Thanks!
谢谢!
might be a good idea to provide more information about your go version
. 提供有关
go version
更多信息可能是一个好主意。 . 。 i have same experience as yours just a weeks ago.
我有几个星期前和您一样的经历。 .
。 i solved it with downgrading my
go version
to version 1.11.1
before i had 1.11.5
and also i check i had two go
installed in my system try checking with command `which golang`
,, i've had the first golang in /usr/local/go
which is my go version that i install manually and the other is from pacman
package manager which is located in usr/local/bin
... 我通过在
1.11.5
之前将go version
降级到1.11.1
来解决了该问题,并且我检查了我的系统中try checking with command `which golang`
安装了两个go
try checking with command `which golang`
,我在/usr/local/go
了第一个golang。 /usr/local/go
是我手动安装的go版本,另一个是usr/local/bin
pacman
软件包管理器。
EDIT :
编辑:
Oh yea, I remember now how to solve my problem : 哦,是的,我现在记得如何解决我的问题:
go mod
cache , mine was under ~/.cache
directory, i dont know bout yours. go mod
cache ,我的在~/.cache
目录下,我不知道你的。 build
your code right away, under your project directory, go ahead and issue go build
build
代码,继续执行并发出go build
EDIT 2 :
编辑2:
i got it now, turns out nothing to do with any of my answer above, just now i stumble ( again ) with this problem,, open up your go.mod
file and edit the first line to : 我现在知道了,结果与上面的任何回答都没有关系,刚才我
go.mod
了这个问题,再次打开go.mod
文件并将第一行编辑为:
module full/path/some/apiOfYours
to just module apiOfYours
module full/path/some/apiOfYours
只是module apiOfYours
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.