Skip to content

Instantly share code, notes, and snippets.

@patrickdevivo
Created August 23, 2021 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickdevivo/ca949754c1661a301b3f84705bfc3301 to your computer and use it in GitHub Desktop.
Save patrickdevivo/ca949754c1661a301b3f84705bfc3301 to your computer and use it in GitHub Desktop.
SELECT
str_split(mod, '/', 0) || '/' || str_split(mod, '/', 1) || '/' || str_split(mod, '/', 2) AS repo, -- this is a bit whacky, need to get the repo part of the module path
contents -- the actual LICENSE file
FROM
(select json_extract(value, '$.mod.path') AS mod from files f, json_each(go_mod_to_json(contents), '$.require') j WHERE f.path = 'go.mod') AS deps,
files('https://' || repo) -- this will clone every every repo to a temp directory
WHERE repo IS NOT NULL
AND path = 'LICENSE'
AND repo LIKE 'github.com%' -- was failing on some non-git dependencies, shortcut for now, but limits to modules only on GitHub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment