#!/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