add go-imports script
authorSteven McDonald <steven@steven-mcdonald.id.au>
Sun, 2 Oct 2011 13:05:06 +0000 (00:05 +1100)
committerSteven McDonald <steven@steven-mcdonald.id.au>
Sun, 2 Oct 2011 13:05:06 +0000 (00:05 +1100)
this is a simple script to list stuff imported from
a set of directories containing go source code.

go-imports [new file with mode: 0755]

diff --git a/go-imports b/go-imports
new file mode 100755 (executable)
index 0000000..7423dc3
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# A simple script to list all imports within one or more directories
+# containing Go source code.
+
+if test -z "$1"
+then
+       echo >&2 "usage: go-imports DIRECTORY"
+       exit 1
+fi
+
+find "$@" -name '*.go' | xargs awk '/import \(/,/\)/ { print $NF }' | tr -d '()"' | sort -u