Skip to content

Instantly share code, notes, and snippets.

@renta
Created October 16, 2024 08:55
Show Gist options
  • Save renta/ffc8aad8f8d422a67110fc349f75a95a to your computer and use it in GitHub Desktop.
Save renta/ffc8aad8f8d422a67110fc349f75a95a to your computer and use it in GitHub Desktop.
Find Go module names and their licenses in the 1-st level of the directory in all Golang modules with .git folder.
#!/bin/sh
set -ex
go install github.com/google/go-licenses@latest
find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && [ -d ".git" ] && [ -f "go.mod" ] && go-licenses report --include_tests --ignore gitlab.my-company.com/my-unit --ignore my-company/awesome-unit ./... >> ../licenses.csv 2> /dev/null" \;
sort licenses.csv > licenses_sort.csv && rm -f licenses.csv && mv licenses_sort.csv licenses.csv
uniq licenses.csv > licenses_uniq.csv && rm -f licenses.csv && mv licenses_uniq.csv licenses.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment