<commit_before>package dragon

import (
	"bufio"
	"go/build"
	"os"
	"path"
	"path/filepath"
	"regexp"
	"strings"

	"golang.org/x/sync/errgroup"
)

var (
	apiFiles = [...]string{"go1.txt", "go1.1.txt", "go1.2.txt", "go1.3.txt", "go1.4.txt", "go1.5.txt"}
	sym      = regexp.MustCompile(`^pkg (\S+).*?, (?:var|func|type|const) ([A-Z]\w*)`)
)

func stdLibs(libChan chan lib) error {
	apiDir := filepath.Join(build.Default.GOROOT, "api")
	eg := &errgroup.Group{}
	for _, f := range apiFiles {
		r, err := os.Open(filepath.Join(apiDir, f))
		if err != nil {
			return err
		}
		eg.Go(func() error {
			sc := bufio.NewScanner(r)
			for sc.Scan() {
				l := sc.Text()
				has := func(v string) bool { return strings.Contains(l, v) }
				if has("struct, ") || has("interface, ") || has(", method (") {
					continue
				}

				if m := sym.FindStringSubmatch(l); m != nil {
					libChan <- lib{
						pkg:    path.Base(m[1]),
						object: m[2],<commit_msg>Add api files for new versions.<commit_after>package dragon

import (
	"bufio"
	"go/build"
	"os"
	"path"
	"path/filepath"
	"regexp"
	"strings"

	"golang.org/x/sync/errgroup"
)

var (
	apiFiles = [...]string{
		"go1.txt",
		"go1.1.txt",
		"go1.2.txt",
		"go1.3.txt",
		"go1.4.txt",
		"go1.5.txt",
		"go1.6.txt",
		"go1.7.txt",
		"go1.8.txt",
		"go1.9.txt",
		"go1.10.txt",
	}
	sym = regexp.MustCompile(`^pkg (\S+).*?, (?:var|func|type|const) ([A-Z]\w*)`)
)

func stdLibs(libChan chan lib) error {
	apiDir := filepath.Join(build.Default.GOROOT, "api")
	eg := &errgroup.Group{}
	for _, f := range apiFiles {
		r, err := os.Open(filepath.Join(apiDir, f))
		if err != nil {
			return err
		}
		eg.Go(func() error {
			sc := bufio.NewScanner(r)
			for sc.Scan() {
				l := sc.Text()
				has := func(v string) bool { return strings.Contains(l, v) }
				if has("struct, ") || has("interface, ") || has(", method (") {
					continue
				}

				if m := sym.FindStringSubmatch(l); m != nil {
					libChan <- lib{
						pkg:    path.Base(m[1]),
						object: m[2],
{'fraction_non_alphanumeric': 0.21860930465232617, 'fraction_numerical': 0.018509254627313655, 'mean_word_length': 2.8910505836575875, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5764693', 'n_tokens_mistral': 971, 'n_tokens_neox': 854, 'n_words': 168}