Skip to content

Instantly share code, notes, and snippets.

@dgnorton
Last active September 29, 2015 00:33
Show Gist options
  • Save dgnorton/cc4dcec04affc0e61f79 to your computer and use it in GitHub Desktop.
Save dgnorton/cc4dcec04affc0e61f79 to your computer and use it in GitHub Desktop.
#!/bin/sh
total=0
# loop through all package directories in the project
for dir in $(go list ./...); do
# prepend $GOPATH src directory
dir="$GOPATH/src/$dir"
# count lines of Go code in the directory
cnt=$(cloc ${dir}/* | egrep "^Go" | awk '{printf $5}')
# print the result
printf "%s: %d\n" "$dir" $cnt
# add to the running total
total=$((total + cnt))
done
# print the grand total
printf "total: %d\n" $total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment