Пример #1
0
func countAll(paths []string, position int) {
	for i := 0; i < len(paths); i++ {
		lines, err := count.LinesInFile(paths[i], true)
		if err != nil {
			panic(err)
		}
		file, ok := countMap[paths[i]]
		if ok == false {
			countMap[paths[i]] = make([]int, *steps+1)
			file = countMap[paths[i]]
		}
		file[position] = lines
	}
}
Пример #2
0
func OpenParallel(paths []string) Files {
	var files Files
	var wg sync.WaitGroup
	for i := 0; i < len(paths); i++ {
		wg.Add(1)
		go func(fp string) {
			lines, err := count.LinesInFile(fp, *ignoreCommentsEmptyLines)
			if err != nil {
				panic(err)
			}
			files = append(files, File{fp, lines})
			wg.Done()
		}(paths[i])
	}
	wg.Wait()
	return files
}
Пример #3
0
func fullInfo(fps []string, elc bool) Files {
	var files Files
	for i := 1; i < len(fps); i++ {
		f, err := os.Open(fps[i])
		if err != nil {
			panic(err)
		}
		info, err := f.Stat()
		if err != nil {
			panic(err)
		}
		lines, err := count.LinesInFile(fps[i], elc)
		if err != nil {
			panic(err)
		}
		files = append(files, File{fps[i], info.Size(), lines})
	}
	return files
}