in admin/lint/checks.go [67:94]
func checkLineLength(workspaceDir string, file string, max int) 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()
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("line length check failed for %s: %v", file, err)
}
line = strings.TrimRight(line, "\n\r")
if len(line) > max {
return fmt.Errorf("line length check failed for %s: line %d exceeds length %d with %d characters", file, lineNo, max, len(line))
}
lineNo++
}
return nil
}