简体   繁体   中英

How to work with a development vendor package managed by dep?

How can I use a development copy/clone of a package while using dep and a vendor directory? The vendor directory is included in the main repository.

For example, I have forked package and replaced it with my own on github. I want to be able to edit the code and not have to git push + dep ensure for each change of the package.

If I clone the package in the vendor directory, it I won't be able to commit that directory into the main repo because it's treated as a separate repository.

I tried a trick to .gitignore the .git directory from outside the package. This works well until dep ensure is run, where the .git directory is nuked.

According to the dep docs , there is no inbuilt way of doing this as it stands.

They also recommend not modifying packages in the vendor directory directly, for the reasons I discovered: it gets nuked when running dep ensure .

Their main suggestion is to manually remove the package from the vendor/ directory, modify it in the regular $GOPATH , and running dep ensure -update <pkg> when finished development of it.

This is sufficiently better than pushing for each change, but still requires to manually push / dep ensure when completing the development work.

An alternative to "ignoring .git " is to keep the .git folder elsewhere! (well outside of your Go project)

Any time you need to execute a git command in the vendored sub-project, you would need to use an alias to the git command, which would be:

alias gg='git --git-dir=/path/to/elsewhere/.git --work-tree=/path/to/vendored/subproject'
# Windows
doskey gg=git --git-dir=C:\path\to\elsewhere\.git --work-tree=C:\path\to\vendored\subproject $*

That way, you can still benefit from version-controled operations within your vendored subproject.

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