Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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