diff options
| author | Nicolas Paul <n@nc0.fr> | 2023-05-31 14:35:06 +0200 |
|---|---|---|
| committer | Nicolas Paul <n@nc0.fr> | 2023-05-31 14:36:16 +0200 |
| commit | 13d764da4e86504da8505677b0e355df16a48110 (patch) | |
| tree | 8576bda1044de4882b5270b3ac3484eccae13a7a | |
| parent | f005e32ae0a22017452a96992b9f6df934c9b3f5 (diff) | |
Make generation async
Signed-off-by: Nicolas Paul <n@nc0.fr>
| -rw-r--r-- | cmd/svgu/svgu.go | 16 | ||||
| -rw-r--r-- | testdata/dst/bitbucket/bar.html | 7 | ||||
| -rw-r--r-- | testdata/dst/foo.html | 7 | ||||
| -rw-r--r-- | testdata/dst/github/bar.html | 7 | ||||
| -rw-r--r-- | testdata/dst/gitiles/bar.html | 7 | ||||
| -rw-r--r-- | testdata/dst/sourcehut/bar.html | 7 |
6 files changed, 13 insertions, 38 deletions
diff --git a/cmd/svgu/svgu.go b/cmd/svgu/svgu.go index 16abcb7..a9d81f6 100644 --- a/cmd/svgu/svgu.go +++ b/cmd/svgu/svgu.go @@ -4,9 +4,11 @@ package main // import "go.nc0.fr/svgu" import ( "flag" "go.nc0.fr/svgu/pkg/config" + "go.nc0.fr/svgu/pkg/types" "log" "os" "path/filepath" + "sync" ) var ( @@ -83,9 +85,17 @@ func main() { log.Printf("generating modules") } + var wg sync.WaitGroup for _, mod := range idx.Modules { - if err := mod.GenerateFile(*out, idx.Domain); err != nil { - log.Fatalf("could not generate module %q: %v", mod.Path, err) - } + wg.Add(1) + go func(m *types.Module) { + defer wg.Done() + if err := m.GenerateFile(*out, idx.Domain); err != nil { + log.Fatalf("could not generate module %q: %v", m.Path, err) + } + }(&mod) } + + wg.Wait() + log.Println("done") } diff --git a/testdata/dst/bitbucket/bar.html b/testdata/dst/bitbucket/bar.html deleted file mode 100644 index 94057c0..0000000 --- a/testdata/dst/bitbucket/bar.html +++ /dev/null @@ -1,7 +0,0 @@ -<!DOCTYPE html> -<meta charset="UTF-8"> -<meta content="example.com/bitbucket/bar git https://root@bitbucket.org/example/bar.git" name="go-import"> -<meta content="example.com/bitbucket/bar https://root@bitbucket.org/example/bar.git https://root@bitbucket.org/example/bar.git/src/default{/dir} https://root@bitbucket.org/example/bar.git/src/default{/dir}/{file}#{file}-{line}" - name="go-source"> -<meta content="width=device-width,initial-scale=1" name="viewport"> -<p>There is nothing to see, redirecting <a href="https://pkg.go.dev/example.com/bitbucket/bar">here</a>.
\ No newline at end of file diff --git a/testdata/dst/foo.html b/testdata/dst/foo.html deleted file mode 100644 index 4b727d7..0000000 --- a/testdata/dst/foo.html +++ /dev/null @@ -1,7 +0,0 @@ -<!DOCTYPE html> -<meta charset="UTF-8"> -<meta content="example.com/foo git https://example.com" name="go-import"> -<meta content="example.com/foo https://example.com https://example.com{/dir} https://example.com{/dir}/{file}" - name="go-source"> -<meta content="width=device-width,initial-scale=1" name="viewport"> -<p>There is nothing to see, redirecting <a href="https://pkg.go.dev/example.com/foo">here</a>.
\ No newline at end of file diff --git a/testdata/dst/github/bar.html b/testdata/dst/github/bar.html deleted file mode 100644 index 70cbeaf..0000000 --- a/testdata/dst/github/bar.html +++ /dev/null @@ -1,7 +0,0 @@ -<!DOCTYPE html> -<meta charset="UTF-8"> -<meta content="example.com/github/bar git https://github.com/example/bar.git" name="go-import"> -<meta content="example.com/github/bar https://github.com/example/bar.git https://github.com/example/bar.git/tree/main{/dir} https://github.com/example/bar.git/blob/main{/dir}/{file}#L{line}" - name="go-source"> -<meta content="width=device-width,initial-scale=1" name="viewport"> -<p>There is nothing to see, redirecting <a href="https://pkg.go.dev/example.com/github/bar">here</a>.
\ No newline at end of file diff --git a/testdata/dst/gitiles/bar.html b/testdata/dst/gitiles/bar.html deleted file mode 100644 index a9ce377..0000000 --- a/testdata/dst/gitiles/bar.html +++ /dev/null @@ -1,7 +0,0 @@ -<!DOCTYPE html> -<meta charset="UTF-8"> -<meta content="example.com/gitiles/bar git https://gerrit.googlesource.com/example/bar.git" name="go-import"> -<meta content="example.com/gitiles/bar https://gerrit.googlesource.com/example/bar.git https://gerrit.googlesource.com/example/bar.git/+/refs/heads/master{/dir} https://gerrit.googlesource.com/example/bar.git/+/refs/heads/master{/dir}/{file}#{line}" - name="go-source"> -<meta content="width=device-width,initial-scale=1" name="viewport"> -<p>There is nothing to see, redirecting <a href="https://pkg.go.dev/example.com/gitiles/bar">here</a>.
\ No newline at end of file diff --git a/testdata/dst/sourcehut/bar.html b/testdata/dst/sourcehut/bar.html deleted file mode 100644 index ec3bb2a..0000000 --- a/testdata/dst/sourcehut/bar.html +++ /dev/null @@ -1,7 +0,0 @@ -<!DOCTYPE html> -<meta charset="UTF-8"> -<meta content="example.com/sourcehut/bar git https://git.sr.ht/~example/bar.git" name="go-import"> -<meta content="example.com/sourcehut/bar https://git.sr.ht/~example/bar.git https://git.sr.ht/~example/bar.git/tree/trunk{/dir} https://git.sr.ht/~example/bar.git/tree/trunk/item{/dir}/{file}#L{line}" - name="go-source"> -<meta content="width=device-width,initial-scale=1" name="viewport"> -<p>There is nothing to see, redirecting <a href="https://pkg.go.dev/example.com/sourcehut/bar">here</a>.
\ No newline at end of file |
