dougua3706 2017-11-29 12:11
浏览 46
已采纳

使用go dep进行Go软件包依赖

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

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.

I am importing with full path: import "github.com/userX/go-project/pkg/package1"

What I am doing wrong?

ENV VARS: GOPATH="/Users/username/go"

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

EDIT: Updated my file structure after dep ensure --update

Basically my steps: 1. go get -u github.com/golang/dep/cmd/dep 2. dep init 3. dep ensure --update

Gopkg.lock contains info about my own project:

[[projects]]
  branch = "master"
  name = "github.com/userX/go-project"
  packages = ["pkg/package1","pkg/package2"]
  revision = "560d3aaasdas53562c3eb083252e54ef8ee468bea74ba"
  • 写回答

1条回答 默认 最新

  • douchuoxuan3177 2017-11-29 15:50
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 husky+jaco2实现在gazebo与rviz中联合仿真
  • ¥15 dpabi预处理报错:Error using y_ExtractROISignal (line 251)
  • ¥15 在虚拟机中配置flume,无法将slave1节点的文件采集到master节点中
  • ¥15 husky+kinova jaco2 仿真
  • ¥15 zigbee终端设备入网失败
  • ¥15 金融监管系统怎么对7+4机构进行监管的
  • ¥15 硬件IIC从模式的数据发送,中断数据的接收,不能用HAL库(按照时序图)
  • ¥20 QAxWidget上显示一个word文档后,如何直接在该QAxWidget上修改和保存word文档
  • ¥15 Simulink仿真报错,请问如何解决
  • ¥20 宝塔面板无法添加Node项目,一直处于正在添加脚本页面