-
Notifications
You must be signed in to change notification settings - Fork 2
/
distribution.go
45 lines (32 loc) · 1.04 KB
/
distribution.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"fmt"
"io/ioutil"
)
func filterDistribution(templates map[string]*Template, contentFile string, flagBools []bool) map[string]int {
counts := map[string]int{}
language, t := determineLanguage(templates, contentFile, flagBools)
if !flagBools[0] && flagBools[2] {
if language != "unknown" {
fmt.Println("language determined as", language)
// XXX multi-line is not accurate
// XXX counting lines that have comments but also code, as code only
commentMarkers := t.Comments
fmt.Printf("whole thing, commentMarkers, %v", commentMarkers)
} else {
fmt.Println("skipping loc filtering for", contentFile, " due to not being able to determine language.")
}
}
// determine language
// strip comments & count lines
// strip white space and count
// count remainder
//coder, _ := regexp.Compile("^[^\\s]
file, err := ioutil.ReadFile(contentFile)
check(err)
if !flagBools[0] && flagBools[2] {
fmt.Println("found", len(file), "characters in file", contentFile)
}
counts["loc"] = len(file)
return counts
}