Skip to content

Instantly share code, notes, and snippets.

@icio icio/go-diff.sh
Created Nov 11, 2016

Embed
What would you like to do?
function go-local-package() {
go list ./... | head -1 | xargs dirname
}
function go-diff() {
ROOT_PKG=$(go-local-package)
go list -f '{{.Name}} {{.ImportPath}} {{.Deps}}' $(go list $ROOT_PKG/...) | \
grep ^main | \
grep -w -f <(
git diff --dirstat ${2:-master}...${1:-HEAD} | \
awk '{ print "'$ROOT_PKG'/" $2 }' | \
sed 's:/$::'
) | \
awk '{ print $2 }'
}
function go-diff-file() {
go-diff "$@" | sed 's:^'$(go-local-package)/'::'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.