diff --git a/output/outputs.go b/output/outputs.go index 0d0d62e..0131c2f 100644 --- a/output/outputs.go +++ b/output/outputs.go @@ -146,7 +146,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) { wsChannel := session.OutputWS[sid] channelRet["cmd"] = "run-done" - channelRet["output"] = string(buf[:count]) + channelRet["output"] = "
" + string(buf[:count]) + "
" err := wsChannel.Conn.WriteJSON(&channelRet) if nil != err { glog.Error(err) @@ -163,7 +163,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) { wsChannel := session.OutputWS[sid] channelRet["cmd"] = "run" - channelRet["output"] = string(buf[:count]) + channelRet["output"] = "
" + string(buf[:count]) + "
" err := wsChannel.Conn.WriteJSON(&channelRet) if nil != err { glog.Error(err) @@ -272,7 +272,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) { if nil != session.OutputWS[sid] { // 在前端 output 中显示“开始构建” - channelRet["output"] = "" + i18n.Get(r, "start-build").(string) + "\n" + channelRet["output"] = "" + i18n.Get(r, "start-build").(string) + "\n" channelRet["cmd"] = "start-build" wsChannel := session.OutputWS[sid] @@ -313,7 +313,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) { if 0 == count { // 说明构建成功,没有错误信息输出 // 设置下一次执行命令(前端会根据该参数发送请求) channelRet["nextCmd"] = args["nextCmd"] - channelRet["output"] = i18n.Get(r, "build-succ").(string) + "\n" + channelRet["output"] = "" + i18n.Get(r, "build-succ").(string) + "\n" go func() { // 运行 go install,生成的库用于 gocode lib-path cmd := exec.Command("go", "install") @@ -329,7 +329,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) { } else { // 构建失败 // 解析错误信息,返回给编辑器 gutter lint errOut := string(buf[:count]) - channelRet["output"] = i18n.Get(r, "build-failed").(string) + "\n" + errOut + channelRet["output"] = "" + i18n.Get(r, "build-failed").(string) + "\n" + errOut lines := strings.Split(errOut, "\n") @@ -465,7 +465,7 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) { if nil != session.OutputWS[sid] { // 在前端 output 中显示“开始 go install” - channelRet["output"] = i18n.Get(r, "start-install").(string) + "\n" + channelRet["output"] = "" + i18n.Get(r, "start-install").(string) + "\n" channelRet["cmd"] = "start-install" wsChannel := session.OutputWS[sid] @@ -500,7 +500,6 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) { count, _ := reader.Read(buf) channelRet := map[string]interface{}{} - channelRet["cmd"] = "go install" if 0 != count { // 构建失败 @@ -547,9 +546,9 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) { channelRet["lints"] = lints - channelRet["output"] = i18n.Get(r, "install-failed").(string) + "\n" + errOut + channelRet["output"] = "" + i18n.Get(r, "install-failed").(string) + "\n" + errOut } else { - channelRet["output"] = i18n.Get(r, "install-succ").(string) + "\n" + channelRet["output"] = "" + i18n.Get(r, "install-succ").(string) + "\n" } if nil != session.OutputWS[sid] { @@ -622,7 +621,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) { if nil != session.OutputWS[sid] { // 在前端 output 中显示“开始 go get - channelRet["output"] = i18n.Get(r, "start-get").(string) + "\n" + channelRet["output"] = "" + i18n.Get(r, "start-get").(string) + "\n" channelRet["cmd"] = "start-get" wsChannel := session.OutputWS[sid] @@ -664,7 +663,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) { if nil != err { glog.V(3).Infof("Session [%s] 's running [go get] [runningId=%d] has done (with error)", sid, runningId) - channelRet["output"] = i18n.Get(r, "get-failed").(string) + "\n" + string(buf[:count]) + channelRet["output"] = "" + i18n.Get(r, "get-failed").(string) + "\n" + string(buf[:count]) if nil != session.OutputWS[sid] { wsChannel := session.OutputWS[sid] @@ -685,7 +684,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) { if 0 == count { glog.V(3).Infof("Session [%s] 's running [go get] [runningId=%d] has done", sid, runningId) - channelRet["output"] = i18n.Get(r, "get-succ").(string) + "\n" + channelRet["output"] = "" + i18n.Get(r, "get-succ").(string) + "\n" if nil != session.OutputWS[sid] { wsChannel := session.OutputWS[sid]