Skip to content

Instantly share code, notes, and snippets.

@achille-roussel
Last active July 20, 2016 07:04
Show Gist options
  • Save achille-roussel/891a700df88ec3f5f539e73f2a859f9b to your computer and use it in GitHub Desktop.
Save achille-roussel/891a700df88ec3f5f539e73f2a859f9b to your computer and use it in GitHub Desktop.
Go: add github vendor submodules
# Run in the root directory of a go package to list all direct github dependencies
# and create git submodules for them in the vendor directory.
for package in $(
go list -f '{{.Deps}}' | tr "[" " " | tr "]" " " | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' | grep github.com | cut -d/ -f1-3 | grep -v $(go list .) | uniq
)
do
git submodule add https://$package vendor/$package
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment