From 9bfaef796eecc9d636ce869af41efd454beb1894 Mon Sep 17 00:00:00 2001 From: mattn Date: Tue, 28 Oct 2014 10:12:32 +0900 Subject: [PATCH 1/2] Handle two columns error format. ex: /path/to/file.go: Permission denied --- output/outputs.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/output/outputs.go b/output/outputs.go index e238d92..8420add 100644 --- a/output/outputs.go +++ b/output/outputs.go @@ -33,7 +33,7 @@ type Lint struct { File string `json:"file"` LineNo int `json:"lineNo"` Severity string `json:"severity"` - Msg string + Msg string `json:"msg"` } // 建立输出通道. @@ -354,8 +354,13 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) { file := line[:strings.Index(line, ":")] left := line[strings.Index(line, ":")+1:] - lineNo, _ := strconv.Atoi(left[:strings.Index(left, ":")]) - msg := left[strings.Index(left, ":")+2:] + index := strings.Index(left, ":") + lineNo := 1 + msg := left + if index >= 0 { + lineNo, _ = strconv.Atoi(left[:index]) + msg = left[index+2:] + } lint := &Lint{ File: file, @@ -621,8 +626,13 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) { file := line[:strings.Index(line, ":")] left := line[strings.Index(line, ":")+1:] - lineNo, _ := strconv.Atoi(left[:strings.Index(left, ":")]) - msg := left[strings.Index(left, ":")+2:] + index := strings.Index(left, ":") + lineNo := 1 + msg := left + if index >= 0 { + lineNo, _ = strconv.Atoi(left[:index]) + msg = left[index+2:] + } lint := &Lint{ File: file, From 1362ad1ea3298be24131afa014547c56bca808f5 Mon Sep 17 00:00:00 2001 From: mattn Date: Tue, 28 Oct 2014 10:16:42 +0900 Subject: [PATCH 2/2] Should be zero to avoid highlight editor --- output/outputs.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/output/outputs.go b/output/outputs.go index 8420add..610a097 100644 --- a/output/outputs.go +++ b/output/outputs.go @@ -355,7 +355,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) { file := line[:strings.Index(line, ":")] left := line[strings.Index(line, ":")+1:] index := strings.Index(left, ":") - lineNo := 1 + lineNo := 0 msg := left if index >= 0 { lineNo, _ = strconv.Atoi(left[:index]) @@ -627,7 +627,7 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) { file := line[:strings.Index(line, ":")] left := line[strings.Index(line, ":")+1:] index := strings.Index(left, ":") - lineNo := 1 + lineNo := 0 msg := left if index >= 0 { lineNo, _ = strconv.Atoi(left[:index])