diff --git a/output/outputs.go b/output/outputs.go index a195a27..5f76076 100644 --- a/output/outputs.go +++ b/output/outputs.go @@ -211,6 +211,9 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) { glog.Warning(string(out)) } }() + } else { // 构建失败 + // 解析错误信息,返回给编辑器 gutter lint + } channelRet := map[string]interface{}{} diff --git a/static/js/editor.js b/static/js/editor.js index 3bc0810..7798d20 100644 --- a/static/js/editor.js +++ b/static/js/editor.js @@ -177,7 +177,7 @@ var editors = { editor.setOption("gutters", ["CodeMirror-lint-markers", "CodeMirror-foldgutter"]); - if ("application/json" === data.mode) { + if ("text/x-go" === data.mode || "application/json" === data.mode) { editor.setOption("lint", true); } diff --git a/static/js/lint/go-lint.js b/static/js/lint/go-lint.js new file mode 100644 index 0000000..e5f8c45 --- /dev/null +++ b/static/js/lint/go-lint.js @@ -0,0 +1,16 @@ +(function(mod) { + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + CodeMirror.registerHelper("lint", "go", function(text) { + var found = []; + + found.push({from: CodeMirror.Pos(1, 1), + to: CodeMirror.Pos(1, 10), + message: "test commpile err"}); + + return found; + }); + +}); diff --git a/view/index.html b/view/index.html index 2d17da9..62e6e74 100644 --- a/view/index.html +++ b/view/index.html @@ -123,6 +123,7 @@ +