2

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"
Marco Talento
  • 2,335
  • 2
  • 19
  • 31
  • If you don't want something in a vendor folder, then don't put it there. You need to show where the vendor folder is, what is in it, and what tool you're using to manage it. – JimB Nov 29 '17 at 13:35
  • Edited my question to add more context! – Marco Talento Nov 29 '17 at 13:58
  • If `vendor/` is in `go-project`, then `dep` should not be adding `go-project` packages to the vendor folder. We need to see how to reproduce the issue. You can also make sure you're using the latest version of `dep`, and fixing the vendor folder yourself, or remove it and start over. – JimB Nov 29 '17 at 14:23
  • Could you show step by step with env bars how you have installed `dep`, started the project and added dependencies to it – Eugene Lisitsky Nov 29 '17 at 14:46

1 Answers1

3

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

Pavlo Strokov
  • 1,967
  • 14
  • 14
  • I have 3 directories at my root folder, (cmd, pkg, vendor) but I dont't have any go file. – Marco Talento Nov 29 '17 at 16:45
  • Your project structure should be: go-project/src/github.com/userX/go-project/cmd go-project/src/github.com/userX/go-project/pkg go-project/src/github.com/userX/go-project/vendor – Pavlo Strokov Nov 29 '17 at 16:52
  • Yup, it was my problem you are right! I have cloned my project to the wrong folder `src/go-project` and not `src/github.com/userX/go-project` :( shame on me! – Marco Talento Nov 29 '17 at 17:04