简体   繁体   中英

How to organise a Go project with vendorised dependencies?

I'm working on a Go project that isn't a package but a service. It depends on mgo , among other things. Because this service is legally supposed to be securely versioned and highly available we've made the decision to vendorize the mgo dependency within the project. Due to the legal requirement we can't just rely on pulling whatever version is on origin/master for the dependency.

Obviously this breaks our GOPATH for all standard commands as it's no longer living under GOPATH but in a vendor directory within the Git repository:

~/src/link_tracker/
  main.go
  main_test.go
  vendor/
    src/
      labix.org/
        etc...

We're currently working around this using a fairly ugly Bash script that mangle lots of environment variables and does some symlinking, but it'd be nice if we could consolidate all this under a Makefile or similar.

What's the best/right way to organise this without losing our specifically versioned dependency of mgo ?

您现在应该使用https://github.com/kr/godep解决此问题非常稳定,需要说明的是您的代码应位于存储库中(git,svn,mercurial等)。

The two tools I've been playing with (for similar goals) are:

You should probably see if you can use one of them instead of rolling your own. In the particular case of the labix.org stuff, johnny-deps appears to require things to be git-hosted.

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