简体   繁体   中英

How to store go dependencies?

I am using GoDep to resolve a project dependencies. My problem is that repositories for dependencies maight be removed and my project wouldn't build.

I am trying to find any solution to store dependencies at Artifactory or another solution.

Please advice.

Regards.

Okay so GoDeps may be the standard way of doing this, but I usually found it a bit complicated. In my opinion, use a Makefile which sets a custom GoPath and just include dependencies with your code (remove their .git folder). This way the version freezes and no one needs to do a godep restore or something similar.

You can make recipes like make deploy that builds your code, runs GoFmt, cleans the pkg files, installs it to your custom GoPath bin/ and then you just go and run the binary.

You can have another one like make install that will install any missing dependencies.

I've managed to create a watch using this on my Makefile to keep on looking for changes on a linux based system using inotify-tools and call rebuild.

Internally all commands will be using standard go commands but you'll get rid of the GoDeps and maintaining JSON. To upgrade a dependency, it may be a bit of a problem as you'd have to manually copy the whole directory into your custom path and remove the .git/ folder.

Our company uses this method and seems to work quite nice for us.

Plus this method basically gets you away the $GOPATH/src/github.com/repoName/ kind of paths.

If i seem unclear, let me know, I'll add a gist on github.

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