Skip to content

Commit

Permalink
Cache go sources
Browse files Browse the repository at this point in the history
This speeds up project loading tremendously.
  • Loading branch information
pgavlin committed Apr 10, 2024
1 parent df578b3 commit 44a6200
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions .dawn/go_sources.dawn
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cache = Cache()

def go_sources(package_dir=None):
packages = {}
visited = set()
Expand Down Expand Up @@ -54,13 +56,15 @@ def go_sources(package_dir=None):
for import_path in packages:
visit_package(import_path)

package_dir = package_dir or "."
package_dir = os.path.abs(package_dir or ".")
def find_all_sources():
mod = json.decode(sh.output("go list -m -json", cwd=package_dir))
if mod["Path"] != "command-line-arguments":
(source, ok) = contains(mod["GoMod"])
if ok:
sources.append(source)

mod = json.decode(sh.output("go list -m -json", cwd=package_dir))
if mod["Path"] != "command-line-arguments":
(source, ok) = contains(mod["GoMod"])
if ok:
sources.append(source)
find_sources(list_packages(package_dir))
return sources

find_sources(list_packages(package_dir or "."))
return sources
return cache.once(package_dir, find_all_sources)

0 comments on commit 44a6200

Please sign in to comment.