Library Dependencies in Go

I created a library / package in Go, and the consensus was that only applications include a vendorfolder in their project, and libraries do not.

So now I included my package in another project ( govendor'ed), and everything worked fine until it got to Jenkins, and that was to use my local resources, where 2 of the dependencies were missing.

My readme file says that all you need to do is go getmy project, and you're done . But this is not the case if you use govendoring.

What should be the approach to my library? Can this be solved, or is this β€œproblem” something that the end user must solve because they are using govendor?

+4
source share
1 answer

It is rather a matter of opinion, I think, but I will share what I use.

I use git subtree to sell subreposites in my tree, then add a line //go:generateto update it later, for example

➜ git subtree add --prefix vendor/xxx/yyy/zzz https://github.com/xxx/yyy/zzz master --squash

Then add //go:generate git subtree pull --prefix vendor/xxx/yyy/zzz https://github.com/xxx/yyy/zzz master --squashlibraries to one of my files.

And just run go generateit before I release.

This is a solution to the issue with the release without the need for any external tools.

Real-time example: https://github.com/OneOfOne/xxhash/blob/master/xxhash_cgo.go

+3
source

All Articles