title: Fast way to find all dirs with a given glob
body: <p>I have the following snippet of shell:</p>
  
  <pre><code>find .                          \
       -not \(                    \
           \(                     \
               -path ./vendor -o  \
               -path ./_\* -o     \
               -path ./.\* -o     \
               -path ./docs -o    \
               -path ./examples   \
           \) -prune              \
       \)                         \
       -type f -name \*.go        \
       | sed 's|^./||'            \
       | xargs -n1 dirname        \
       | sort -u                  \
  </code></pre>
  
  <p>It works, but it takes 4-5 seconds to run.  I'm looking for ideas on how to make it faster.  Any directory with a single *.go file qualifies.  Output must be just the directory names, and must be <code>dir/subdir</code> not <code>./dir/subdir</code></p>
  
  <p>edit: This dir-tree has thousands of files in many hundreds of directories. I expect to find O(hundreds) of directories that match.</p>
  
  <p>Any clever ideas, O shell wizards?</p>