Skip to content

Commit

Permalink
chore: add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Zxilly committed Feb 12, 2024
1 parent 3d7e9a0 commit 9590716
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions gen/goversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import (
)

func generateGoVersions() {
fmt.Println("Generating " + goversionOutputFile + "&" + goversionCsv)

ctx := context.Background()

opts := &github.ListOptions{PerPage: 100}
Expand Down Expand Up @@ -129,4 +131,6 @@ func generateGoVersions() {
}

writeOnDemand(buf.Bytes(), goversionOutputFile)

fmt.Println("Generated " + goversionOutputFile + "&" + goversionCsv)
}
2 changes: 2 additions & 0 deletions gen/moduledata.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ func (g *moduleDataGenerator) writeVersionedModuleData(versionCode int, code str
}

func generateModuleData() {
fmt.Printf("Generating %s...", moduleDataOutputFile)

sources, err := getModuleDataSources()
if err != nil {
panic(err)
Expand Down
2 changes: 1 addition & 1 deletion gen/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ import "fmt"

var (
goversionCsv = filepath.Join(getSourceDir(), "resources", "goversions.csv")
outputFile = filepath.Join(getSourceDir(), "stdpkg_gen.go")
stdpkgOutputFile = filepath.Join(getSourceDir(), "stdpkg_gen.go")
goversionOutputFile = filepath.Join(getSourceDir(), "goversion_gen.go")
moduleDataOutputFile = filepath.Join(getSourceDir(), "moduledata_gen.go")
)
16 changes: 14 additions & 2 deletions gen/stdpkgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ import (
)

func generateStdPkgs() {
fmt.Println("Generating " + stdpkgOutputFile)

logChan := make(chan string)
go func() {
for log := range logChan {
fmt.Println(log)
}
}()

wg := &sync.WaitGroup{}
collect := func(ctx context.Context, cause context.CancelCauseFunc, tag string, result chan []string) {
tree, _, err := githubClient.Git.GetTree(ctx, "golang", "go", tag, true)
Expand All @@ -37,7 +46,7 @@ func generateStdPkgs() {
return
}

fmt.Println("Fetched std pkgs for tag:", tag)
logChan <- "Fetched std pkgs for tag: " + tag

if len(tree.Entries) == 100000 {
fmt.Printf("Warning: tree %s has 100000 entries, this may be limited by api, some might be missing", tag)
Expand Down Expand Up @@ -86,6 +95,7 @@ func generateStdPkgs() {
go func() {
wg.Wait()
close(pkgsChan)
close(logChan)
}()

for pkgs := range pkgsChan {
Expand Down Expand Up @@ -117,5 +127,7 @@ func generateStdPkgs() {
return
}

writeOnDemand(buf.Bytes(), outputFile)
writeOnDemand(buf.Bytes(), stdpkgOutputFile)

fmt.Println("Generated " + stdpkgOutputFile)
}

0 comments on commit 9590716

Please sign in to comment.