Before I used go dep
, but now office ensure the official tool is go mod
.
When I use go dep
, I can add local dependency packages to vendor and ignored
in Gopkg.toml
to ignore search the package from repo. I can execute go dep update
normally.
Now I use go mod
, I also add local dependence package to vendor and add it exclude
in go.mod
. But when i execute go mod tidy
, it remove the package even though my project exist import xxx
.
What did i do:
- create new project
- execute go mod init
modify go.mod
exclude privaterepo.com/bb/bb
copy my local module to vendor because the local module is on a private repo which not support https.
- now the vendor just like:
vendor |-github.com/aa/aa |-privaterepo.com/bb/bb
- import "privaterepo.com/bb/bb"
- execute go build -mod vendor
- than i got error "cannot find module for path privaterepo.com/bb/bb" 9 always try with replace, but it also not work
So, what should I do to add local package to vendor and avoid go mod
remove it?