in admin/lint/checks.go [98:126]
func checkNoTabs(workspaceDir string, file string) error {
input, err := os.OpenFile(file, os.O_RDONLY, 0)
if err != nil {
return fmt.Errorf("failed to open %s for read: %v", file, err)
}
defer input.Close()
preg := regexp.MustCompile(`^ *\t`)
reader := bufio.NewReader(input)
lineNo := 1
done := false
for !done {
line, err := reader.ReadString('\n')
if err == io.EOF {
done = true
// Fall through to process the last line in case it's not empty (when the
// file didn't end with a newline).
} else if err != nil {
return fmt.Errorf("no tabs check failed for %s: %v", file, err)
}
if preg.MatchString(line) {
return fmt.Errorf("no tabs check failed for %s: indentation tabs found at line %d", file, lineNo)
}
lineNo++
}
return nil
}