问题描述
我在同一个github存储库中具有以下项目结构:
I have the following project structure in the same github repository:
https://github.com/userX/go-project/cmd/server/main.go
https://github.com/userX/go-project/pkg/package1
https://github.com/userX/go-project/pkg/package2
https://github.com/userX/go-project/pkg/package2
https://github.com/userX/go-project/Gopkg.toml
由于某种原因,我的项目作为依赖项存在于文件夹供应商中.而且ofc我也不希望这样,因为如果我更改package1
,则需要先将其推送以使package2
中包含最新的更改.因为它使用的是供应商文件夹中的文件.
And for some reason my project is in folder vendor as a dependency. And ofc I don't want that because if I change package1
I need to push it first to have the latest changes inside package2
. Because it's using files inside vendor folder.
我正在导入完整路径:import "github.com/userX/go-project/pkg/package1"
I am importing with full path: import "github.com/userX/go-project/pkg/package1"
我做错了什么?
ENV VARS:GOPATH="/Users/username/go"
ENV VARS: GOPATH="/Users/username/go"
vendor
文件夹位于项目的根文件夹中,我正在使用dep
( https://github.com/golang/dep )来管理我的依赖项!
vendor
folder is in the root folder of the project and I am using dep
(https://github.com/golang/dep) to manage my dependencies!
在供应商文件夹中,我可以找到第三方库以及自己的项目.
Inside my vendor folder I can find my third party libraries and also my own project.
├── Dockerfile
├── Gopkg.lock
├── Gopkg.toml
├── LICENSE
├── Makefile
├── README.md
├── cmd
│ ├── server
│ │ └── main.go
│ └── cli
│ └── main.go
├── docker-compose.yml
├── pkg
│ ├── package1
│ │ ├── file.go
│ ├── package2
│ │ └── file.go
└── vendor
└── github.com
├── julienschmidt
│ └── httprouter
│ ├── LICENSE
└── userX
└── go-project
├── Dockerfile
├── Gopkg.lock
├── Gopkg.toml
├── LICENSE
├── Makefile
├── README.md
├── cmd
│ ├── server
│ │ └── main.go
│ └── cli
│ └── main.go
├── docker-compose.yml
└── pkg
├── package1
│ ├── file.go
├── pacakge2
└── file.go
dep ensure --update
基本上我的步骤: 1.去-u github.com/golang/dep/cmd/dep 2.初始化 3.保证--update
Basically my steps: 1. go get -u github.com/golang/dep/cmd/dep 2. dep init 3. dep ensure --update
Gopkg.lock包含有关我自己的项目的信息:
Gopkg.lock contains info about my own project:
[[projects]]
branch = "master"
name = "github.com/userX/go-project"
packages = ["pkg/package1","pkg/package2"]
revision = "560d3aaasdas53562c3eb083252e54ef8ee468bea74ba"
推荐答案
看起来您应该看看项目结构,因为在我看来,您拥有的唯一目录是vendor
目录.并查看供应商目录
Looks like you should take a look at project structure, because for me it looks like only directory you have is a vendor
directory. And also take a look at vendor directories
这篇关于使用go dep进行Go软件包依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!