Merge pull request #109 from mattn/handle-error

Handle two columns error format. ex: /path/to/file.go: Permission denied
This commit is contained in:
Liang Ding 2014-10-28 13:24:44 +08:00
commit 780c0903b5
1 changed files with 15 additions and 5 deletions

View File

@ -34,7 +34,7 @@ type Lint struct {
File string `json:"file"` File string `json:"file"`
LineNo int `json:"lineNo"` LineNo int `json:"lineNo"`
Severity string `json:"severity"` Severity string `json:"severity"`
Msg string Msg string `json:"msg"`
} }
// 建立输出通道. // 建立输出通道.
@ -355,8 +355,13 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
file := line[:strings.Index(line, ":")] file := line[:strings.Index(line, ":")]
left := line[strings.Index(line, ":")+1:] left := line[strings.Index(line, ":")+1:]
lineNo, _ := strconv.Atoi(left[:strings.Index(left, ":")]) index := strings.Index(left, ":")
msg := left[strings.Index(left, ":")+2:] lineNo := 0
msg := left
if index >= 0 {
lineNo, _ = strconv.Atoi(left[:index])
msg = left[index+2:]
}
lint := &Lint{ lint := &Lint{
File: file, File: file,
@ -622,8 +627,13 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
file := line[:strings.Index(line, ":")] file := line[:strings.Index(line, ":")]
left := line[strings.Index(line, ":")+1:] left := line[strings.Index(line, ":")+1:]
lineNo, _ := strconv.Atoi(left[:strings.Index(left, ":")]) index := strings.Index(left, ":")
msg := left[strings.Index(left, ":")+2:] lineNo := 0
msg := left
if index >= 0 {
lineNo, _ = strconv.Atoi(left[:index])
msg = left[index+2:]
}
lint := &Lint{ lint := &Lint{
File: file, File: file,