简体   繁体   中英

How to do a Go project workspace to work with dependencies tools and go tools?

I have a project with packages inside:

  • project package "root": a/b/c (eg github/b/c)
  • in a/b/c we have a lot of packages (p1, p2 ...)
  • project is managed according to How to Write Go Code official recommendations. The local project path is: $GOPATH/src/a/b/c . Also all imports are "not relative".
  • the project has go get -able dependencies

Now I want to use some dependency manager tool like gom or godep . Each of this tool creates an extra directory in repository and puts all vendor dependencies there. Also it plays with GOPATH and sets it to that vendor directory. Let's assume that the tool will put all vendors in path_to_project/.vendor - becoming a new GOPATH .

I want to use one of the go tools ( gofmt , gorename , ...) being aware about packages in my projects and vendor directory. The problem is that if GOPATH=path_to_project/.vendor ( godep does this) then tools are not aware about packages in my project.

One idea for this is to set a GOPATH=path_to_project/.vendor:GOPATH in a shell end editors. Or call every command with gom exec (gom sets a GOPATH in the above proposition)

Is there any ready and automatic solution for this?

Final goal is to bundle go project with specified dependencies versions (like git commits) and make tools + editors (vim/emacs) working with this tools.

If you are using godep, you can just prefix the go command with godep like this:

godep go build

or

godep go fmt 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM