<commit_before>package main

import (
	"fmt"
	"log"
	"os"

	"github.com/simulatedsimian/strk/streak"
)

type repoCommits struct {
	repoName string
	*streak.CommitsJSON
}

func main() {

	repoChan := make(chan string)
	commitsChan := make(chan repoCommits)

	go func() {
		repos, err := streak.GetRepos("simulatedsimian", os.Args[1])
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}

		for _, v := range *repos {
			repoChan <- v.Name
		}
		close(repoChan)
	}()

	for n := 0; n < 16; n++ {
		go func(n int) {
			log.Println("Staring go func", n)
			for {
				name := <-repoChan
				if name == "" {
					break
				}
				log.Println("Fetching commits for repo: ", name)

				commits, err := streak.GetCommits("simulatedsimian", name, os.Args[1])
				if err != nil {
					fmt.Println(err)
					os.Exit(1)
				}
				commitsChan <- repoCommits{name, commits}
			}
			log.Println("End go func", n)
		}(n)
	}

	for {
		res := <-commitsChan
		log.Println(res.repoName, len(*res.CommitsJSON))
	}<commit_msg>experimenting with multiple concurrent requests<commit_after>package main

import (
	"fmt"
	"log"
	"os"

	"github.com/simulatedsimian/strk/streak"
)

type repoCommits struct {
	repoName string
	*streak.CommitsJSON
}

func main() {

	repoChan := make(chan string)
	commitsChan := make(chan repoCommits)

	for n := 0; n < 8; n++ {
		go func(n int) {
			log.Println("Staring go func", n)
			for {
				name := <-repoChan
				if name == "" {
					break
				}
				log.Println("Fetching commits for repo: ", name)

				commits, err := streak.GetCommits("simulatedsimian", name, os.Args[1])
				if err != nil {
					fmt.Println(err)
					os.Exit(1)
				}
				commitsChan <- repoCommits{name, commits}
			}
			log.Println("End go func", n)
		}(n)
	}

	repos, err := streak.GetRepos("simulatedsimian", os.Args[1])
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	go func() {
		for _, v := range *repos {
			repoChan <- v.Name
		}
		close(repoChan)
	}()

	for n := 0; n < len(*repos); n++ {
		res := <-commitsChan
		log.Println(res.repoName, len(*res.CommitsJSON))
	}
{'fraction_non_alphanumeric': 0.15980629539951574, 'fraction_numerical': 0.006779661016949152, 'mean_word_length': 2.920303605313093, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2050943', 'n_tokens_mistral': 972, 'n_tokens_neox': 805, 'n_words': 181}