BruceAuyeung
BruceAuyeung

Reputation: 73

should we always place our own packages in vendor/ folder when developing a golang library?

recently i read a article http://glide.readthedocs.io/en/latest/vendor/, there are some recommendations, one of them is :

Libraries (codebases without a main package) should not store outside packages in a vendor/ folder in their VCS unless they have a specific reason and understand why they're doing it.

my question is :

according to this recommendation, should we always place our own packages(not those third party packages) in vendor/ folder when developing a golang library ?

Upvotes: 0

Views: 1607

Answers (2)

T. Claverie
T. Claverie

Reputation: 12246

No, it makes no sense to add your own packages inside a vendor/ directory, because the vendor directory is meant for code external to your project.

What this recommendation means is: If you are developing a library, do not use vendor/ to store third-party libraries unless you know what you're doing and why you're doing it.

Upvotes: 1

Plato
Plato

Reputation: 11052

"outside packages" means packages that live outside this repo. So, if the packages are in separate repos from the code that imports them: Yes, vendor them.

If you just want to write and use multiple packages while implementing your library: No, put them in subfolders outside vendor/ in the library repo

For example

... ▸ server/ server.go "package server" ▸ store/ ▸ testutils/ ▾ vendor/ ▸ bitbucket.org/ ▸ github.com/ ...

Upvotes: 1

Related Questions