commit
70e4b4efca
|
@ -11,13 +11,13 @@
|
|||
"RuntimeMode": "dev",
|
||||
"Pwd": "{pwd}",
|
||||
"Workspace": "{pwd}/data/workspace",
|
||||
"Locale": "zh_CN",
|
||||
"Locale": "en_US",
|
||||
"Users": [
|
||||
{
|
||||
"Name": "admin",
|
||||
"Password": "admin",
|
||||
"Workspace": "{pwd}/data/user_workspaces/admin",
|
||||
"Locale": "zh_CN",
|
||||
"Locale": "en_US",
|
||||
"GoFormat": "gofmt",
|
||||
"LatestSessionContent": {
|
||||
"FileTree": [],
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_Division_1(t *testing.T) {
|
||||
if i, e := Division(6, 2); i != 3 || e != nil { //try a unit test on function
|
||||
t.Error("除法函数测试没通过") // 如果不是如预期的那么就报错
|
||||
} else {
|
||||
t.Log("第一个测试通过了") //记录一些你期望记录的信息
|
||||
}
|
||||
}
|
||||
|
||||
func Test_Division_2(t *testing.T) {
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_Division_3(t *testing.T) {
|
||||
if i, e := Division(6, 2); i != 3 || e != nil { //try a unit test on function
|
||||
t.Error("除法函数测试没通过") // 如果不是如预期的那么就报错
|
||||
} else {
|
||||
t.Log("第一个测试通过了") //记录一些你期望记录的信息
|
||||
}
|
||||
}
|
||||
|
||||
func Test_Division_4(t *testing.T) {
|
||||
t.Error("就是不通过")
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
func Division(a, b float64) (float64, error) {
|
||||
if b == 0 {
|
||||
return 0, errors.New("除数不能为0")
|
||||
}
|
||||
|
||||
return a / b, nil
|
||||
}
|
|
@ -1,411 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>
|
||||
{{.i18n.wide}}
|
||||
|
||||
</title>
|
||||
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/codemirror.css">
|
||||
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/addon/hint/show-hint.css">
|
||||
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/addon/lint/lint.css">
|
||||
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/addon/fold/foldgutter.css">
|
||||
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/theme/wide.css">
|
||||
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/js/lib/ztree/zTreeStyle.css">
|
||||
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/dialog.css?{{.conf.StaticResourceVersion}}">
|
||||
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/base.css?{{.conf.StaticResourceVersion}}">
|
||||
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/wide.css?{{.conf.StaticResourceVersion}}">
|
||||
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/side.css?{{.conf.StaticResourceVersion}}">
|
||||
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/start.css?{{.conf.StaticResourceVersion}}">
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<!-- 主菜单 -->
|
||||
<div class="menu fn-clear">
|
||||
<ul class="fn-cleaer">
|
||||
<li>
|
||||
<span>
|
||||
{{.i18n.file}}
|
||||
|
||||
</span>
|
||||
<div class="frame">
|
||||
<ul>
|
||||
<li class="save-all disabled" onclick="wide.saveAllFiles()">
|
||||
<span>
|
||||
{{.i18n.save_all_files}}
|
||||
|
||||
</span>
|
||||
</li>
|
||||
<li class="close-all disabled" onclick="wide.closeAllFiles()">
|
||||
<span>
|
||||
{{.i18n.close_all_files}}
|
||||
|
||||
</span>
|
||||
</li>
|
||||
<li class="hr">
|
||||
</li>
|
||||
<li onclick="wide.exit()">
|
||||
<span>
|
||||
{{.i18n.exit}}
|
||||
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<span>
|
||||
{{.i18n.run}}
|
||||
|
||||
</span>
|
||||
<div class="frame">
|
||||
<ul>
|
||||
<li class="run disabled" onclick="wide.run()">
|
||||
<span>
|
||||
{{.i18n.build_n_run}}
|
||||
|
||||
</span>
|
||||
</li>
|
||||
<li class="hr">
|
||||
</li>
|
||||
<li class="go-get disabled" onclick="wide.goget()">
|
||||
<span>
|
||||
{{.i18n.goget}}
|
||||
|
||||
</span>
|
||||
</li>
|
||||
<li class="go-install disabled" onclick="wide.goinstall()">
|
||||
<span>
|
||||
{{.i18n.goinstall}}
|
||||
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<!--
|
||||
<li>
|
||||
<span>{{.i18n.debug}}</span>
|
||||
<div class="frame">
|
||||
<ul>
|
||||
<li>
|
||||
<span>{{.i18n.debug}}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
-->
|
||||
<li>
|
||||
<span>
|
||||
{{.i18n.help}}
|
||||
|
||||
</span>
|
||||
<div class="frame">
|
||||
<ul>
|
||||
<li onclick="window.open('https://www.gitbook.io/book/88250/wide-user-guide')">
|
||||
<span>
|
||||
{{.i18n.wide_doc}}
|
||||
|
||||
</span>
|
||||
</li>
|
||||
<li onclick="window.open('https://github.com/b3log/wide/issues/new')">
|
||||
{{.i18n.report_issues}}
|
||||
|
||||
</li>
|
||||
<li class="hr">
|
||||
</li>
|
||||
<li onclick="editors.openStartPage()">
|
||||
<span>
|
||||
{{.i18n.start_page}}
|
||||
|
||||
</span>
|
||||
</li>
|
||||
<li onclick="wide.openAbout()">
|
||||
<span>
|
||||
{{.i18n.about}}
|
||||
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="side">
|
||||
<span title="{{.i18n.min}}" class="font-ico ico-min">
|
||||
</span>
|
||||
<div class="tabs">
|
||||
<div class="current" data-index="filreTree">
|
||||
<span title="{{.i18n.file}}">
|
||||
{{.i18n.file}}
|
||||
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tabs-panel">
|
||||
<div data-index="filreTree">
|
||||
<ul id="files" tabindex="-1" class="ztree">
|
||||
</ul>
|
||||
<!-- 目录右键菜单 -->
|
||||
<div id="dirRMenu" class="frame">
|
||||
<ul>
|
||||
<li onclick="tree.newFile();">
|
||||
{{.i18n.create_file}}
|
||||
|
||||
</li>
|
||||
<li onclick="tree.newDir();">
|
||||
{{.i18n.create_dir}}
|
||||
|
||||
</li>
|
||||
<li onclick="tree.removeIt();">
|
||||
{{.i18n.delete}}
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- 文件右键菜单 -->
|
||||
<div id="fileRMenu" class="frame">
|
||||
<ul>
|
||||
<li onclick="tree.removeIt();">
|
||||
{{.i18n.delete}}
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="edit-panel">
|
||||
<div class="toolbars fn-none">
|
||||
<span onclick="wide.run()" class="font-ico ico-buildrun" title="{{.i18n.build_n_run}}">
|
||||
</span>
|
||||
<span onclick="wide.saveFile()" title="{{.i18n.save}}" class="font-ico ico-save">
|
||||
</span>
|
||||
<span onclick="wide.fmt(editors.getCurrentPath(), wide.curEditor)" class="ico-format font-ico" title="{{.i18n.format}}">
|
||||
</span>
|
||||
<span class="font-ico ico-max" onclick="windows.maxEditor()" title="{{.i18n.max_editor}}">
|
||||
</span>
|
||||
</div>
|
||||
<div class="tabs">
|
||||
</div>
|
||||
<div class="tabs-panel">
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom-window-group">
|
||||
<span title="{{.i18n.min}}" class="font-ico ico-min">
|
||||
</span>
|
||||
<div class="tabs">
|
||||
<div class="current" data-index="output">
|
||||
<span title="{{.i18n.output}}">
|
||||
{{.i18n.output}}
|
||||
|
||||
</span>
|
||||
</div>
|
||||
<div data-index="search">
|
||||
<span title="{{.i18n.search}}">
|
||||
{{.i18n.search}}
|
||||
|
||||
</span>
|
||||
</div>
|
||||
<div data-index="notification">
|
||||
<span title="{{.i18n.notification}}">
|
||||
{{.i18n.notification}}
|
||||
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tabs-panel">
|
||||
<div data-index="output">
|
||||
<textarea class="output">
|
||||
</textarea>
|
||||
</div>
|
||||
<div class="fn-none" data-index="search">
|
||||
<div tabindex="-1" class="search">
|
||||
<div class="tabs fn-none">
|
||||
<div class="current" data-index="first">
|
||||
<span class="first">
|
||||
</span>
|
||||
<span class="ico-close font-ico">
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tabs-panel">
|
||||
<div data-index="first">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fn-none" data-index="notification">
|
||||
<div tabindex="-1" class="notification">
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer fn-clear">
|
||||
<div class="fn-left">
|
||||
<span title="{{.i18n.restore_side}}" class="font-ico ico-restore fn-none">
|
||||
</span>
|
||||
<span title="{{.i18n.resotre_bottom}}" class="font-ico ico-restore fn-none">
|
||||
</span>
|
||||
</div>
|
||||
<div class="fn-right">
|
||||
<span class="cursor">
|
||||
</span>
|
||||
<span class="notification-count" title="{{.i18n.unread_notification}}">
|
||||
{{.i18n.notification}}!
|
||||
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="dialogRemoveConfirm" class="fn-none">
|
||||
{{.i18n.isDelete}}
|
||||
|
||||
<b>
|
||||
</b>
|
||||
?
|
||||
|
||||
</div>
|
||||
<div id="dialogAlert" class="fn-none">
|
||||
</div>
|
||||
<div id="dialogNewFilePrompt" class="dialog-prompt fn-none">
|
||||
<input/>
|
||||
</div>
|
||||
<div id="dialogNewDirPrompt" class="dialog-prompt fn-none">
|
||||
<input/>
|
||||
</div>
|
||||
<div id="dialogGoLinePrompt" class="dialog-prompt fn-none">
|
||||
<input/>
|
||||
</div>
|
||||
<div id="dialogSearchForm" class="dialog-form fn-none">
|
||||
<input placeholder="{{.i18n.keyword}}" />
|
||||
<input placeholder="{{.i18n.file_format}}" />
|
||||
</div>
|
||||
<script>
|
||||
var config = {
|
||||
"pathSeparator": {{.pathSeparator}},
|
||||
"latestSessionContent": {{.latestSessionContent}},
|
||||
"label": {
|
||||
"restore_editor": "{{.i18n.restore_editor}}",
|
||||
"max_editor": "{{.i18n.max_editor}}",
|
||||
"delete": "{{.i18n.delete}}",
|
||||
"cancel": "{{.i18n.cancel}}",
|
||||
"goto_line": "{{.i18n.goto_line}}",
|
||||
"goto": "{{.i18n.goto}}",
|
||||
"create": "{{.i18n.create}}",
|
||||
"create_file": "{{.i18n.create_file}}",
|
||||
"create_dir": "{{.i18n.create_dir}}",
|
||||
"tip": "{{.i18n.tip}}",
|
||||
"confirm": "{{.i18n.confirm}}",
|
||||
"build_n_run": "{{.i18n.build_n_run}}",
|
||||
"stop": "{{.i18n.stop}}",
|
||||
"usages": "{{.i18n.find_usages}}",
|
||||
"search_text": "{{.i18n.search_text}}",
|
||||
"search": "{{.i18n.search}}",
|
||||
"initialise": "{{.i18n.initialise}}",
|
||||
"confirm_save": "{{.i18n.confirm_save}}"
|
||||
},
|
||||
"channel": {
|
||||
"editor": '{{.conf.EditorChannel}}',
|
||||
"shell": '{{.conf.ShellChannel}}',
|
||||
"output": '{{.conf.OutputChannel}}',
|
||||
"session": '{{.conf.SessionChannel}}'
|
||||
},
|
||||
"wideSessionId": '{{.session.Id}}'
|
||||
};
|
||||
// 发往 Wide 的所有 AJAX 请求需要使用该函数创建请求参数.
|
||||
function newWideRequest() {
|
||||
var ret = {
|
||||
sid: config.wideSessionId
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/jquery-2.1.1.min.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/reconnecting-websocket.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/ztree/jquery.ztree.all-3.5.min.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/codemirror.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/addon/lint/lint.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/addon/lint/json-lint.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/addon/selection/active-line.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/overwrite/codemirror-4.5/addon/hint/show-hint.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/addon/hint/anyword-hint.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/addon/display/rulers.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/addon/edit/closebrackets.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/addon/edit/matchbrackets.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/addon/edit/closetag.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/addon/search/searchcursor.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/addon/search/match-highlighter.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/addon/fold/foldcode.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/addon/fold/foldgutter.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/addon/fold/brace-fold.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/addon/fold/xml-fold.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/addon/fold/markdown-fold.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/addon/fold/comment-fold.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/mode/go/go.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/mode/xml/xml.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/mode/htmlmixed/htmlmixed.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/mode/javascript/javascript.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/mode/markdown/markdown.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/mode/css/css.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/mode/shell/shell.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/codemirror-4.5/mode/sql/sql.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/lint/json-lint.js?{{.conf.StaticResourceVersion}}">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/lib/lint/go-lint.js?{{.conf.StaticResourceVersion}}">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/tabs.js?{{.conf.StaticResourceVersion}}">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/dialog.js?{{.conf.StaticResourceVersion}}">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/editors.js?{{.conf.StaticResourceVersion}}">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/notification.js?{{.conf.StaticResourceVersion}}">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/tree.js?{{.conf.StaticResourceVersion}}">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/wide.js?{{.conf.StaticResourceVersion}}">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/session.js?{{.conf.StaticResourceVersion}}">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/menu.js?{{.conf.StaticResourceVersion}}">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/windows.js?{{.conf.StaticResourceVersion}}">
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.conf.StaticServer}}/static/js/hotkeys.js?{{.conf.StaticResourceVersion}}">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -2,8 +2,8 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"mytest/time/pkg"
|
||||
"time"
|
||||
"time/pkg"
|
||||
)
|
||||
|
||||
func main() {
|
|
@ -7,7 +7,7 @@
|
|||
"username": "Username",
|
||||
"current_user": "Current User",
|
||||
"password": "Password",
|
||||
"login_failed": "Login Failed",
|
||||
"login_error": "Login Error",
|
||||
"run": "Run",
|
||||
"debug": "Debug",
|
||||
"help": "Help",
|
||||
|
@ -86,13 +86,16 @@
|
|||
"focus_notification": "Focus to Notification",
|
||||
"start-build": "START [go build]",
|
||||
"build-succ": "[go build] SUCCESS",
|
||||
"build-failed": "[go build] Failed",
|
||||
"build-error": "[go build] ERROR",
|
||||
"start-test": "START [go test]",
|
||||
"test-succ": "[go test] SUCCESS",
|
||||
"test-error": "[go test] ERROR",
|
||||
"start-install": "START [go install]",
|
||||
"install-succ": "[go install] SUCCESS",
|
||||
"install-failed": "[go install] Fialed",
|
||||
"install-error": "[go install] ERROR",
|
||||
"start-get": "START [go get]",
|
||||
"get-succ": "[go get] SUCCESS",
|
||||
"get-failed": "[go get] Failed",
|
||||
"get-error": "[go get] ERROR",
|
||||
"check_version": "Checking update",
|
||||
"new_version_available": "new version available",
|
||||
"go_env": "Go",
|
||||
|
@ -101,5 +104,6 @@
|
|||
"license": "License",
|
||||
"credits": "Credits",
|
||||
"uptodate": "it is up to date",
|
||||
"test": "Test",
|
||||
"colon": ": "
|
||||
}
|
|
@ -7,7 +7,7 @@
|
|||
"username": "用户名",
|
||||
"current_user": "当前用户",
|
||||
"password": "密码",
|
||||
"login_failed": "登录失败",
|
||||
"login_error": "登录失败",
|
||||
"run": "运行",
|
||||
"debug": "调试",
|
||||
"help": "帮助",
|
||||
|
@ -86,13 +86,16 @@
|
|||
"focus_notification": "焦点切换到通知窗口",
|
||||
"start-build": "开始 [go build]",
|
||||
"build-succ": "[go build] 成功",
|
||||
"build-failed": "[go build] 失败",
|
||||
"build-error": "[go build] 失败",
|
||||
"start-test": "开始 [go test]",
|
||||
"test-succ": "[go test] 成功",
|
||||
"test-error": "[go test] 失败",
|
||||
"start-install": "开始 [go install]",
|
||||
"install-succ": "[go install] 成功",
|
||||
"install-failed": "[go install] 失败",
|
||||
"install-error": "[go install] 失败",
|
||||
"start-get": "开始 [go get]",
|
||||
"get-succ": "[go get] 成功",
|
||||
"get-failed": "[go get] 失败",
|
||||
"get-error": "[go get] 失败",
|
||||
"check_version": "正在检查更新",
|
||||
"new_version_available": "新版本可用",
|
||||
"go_env": "Go 环境",
|
||||
|
@ -101,5 +104,6 @@
|
|||
"license": "许可协议",
|
||||
"credits": "致谢",
|
||||
"uptodate": "已是最新版本",
|
||||
"test": "测试",
|
||||
"colon": ":"
|
||||
}
|
1
main.go
1
main.go
|
@ -294,6 +294,7 @@ func main() {
|
|||
http.HandleFunc("/build", handlerWrapper(output.BuildHandler))
|
||||
http.HandleFunc("/run", handlerWrapper(output.RunHandler))
|
||||
http.HandleFunc("/stop", handlerWrapper(output.StopHandler))
|
||||
http.HandleFunc("/go/test", handlerWrapper(output.GoTestHandler))
|
||||
http.HandleFunc("/go/get", handlerWrapper(output.GoGetHandler))
|
||||
http.HandleFunc("/go/install", handlerWrapper(output.GoInstallHandler))
|
||||
http.HandleFunc("/output/ws", handlerWrapper(output.WSHandler))
|
||||
|
|
|
@ -56,11 +56,9 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
|||
data := map[string]interface{}{"succ": true}
|
||||
defer util.RetJSON(w, r, data)
|
||||
|
||||
decoder := json.NewDecoder(r.Body)
|
||||
|
||||
var args map[string]interface{}
|
||||
|
||||
if err := decoder.Decode(&args); err != nil {
|
||||
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
|
||||
glog.Error(err)
|
||||
data["succ"] = false
|
||||
|
||||
|
@ -188,11 +186,9 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
|||
username := httpSession.Values["username"].(string)
|
||||
locale := conf.Wide.GetUser(username).Locale
|
||||
|
||||
decoder := json.NewDecoder(r.Body)
|
||||
|
||||
var args map[string]interface{}
|
||||
|
||||
if err := decoder.Decode(&args); err != nil {
|
||||
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
|
||||
glog.Error(err)
|
||||
data["succ"] = false
|
||||
|
||||
|
@ -330,7 +326,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
|||
} else { // 构建失败
|
||||
// 解析错误信息,返回给编辑器 gutter lint
|
||||
errOut := string(buf)
|
||||
channelRet["output"] = "<span class='build-failed'>" + i18n.Get(locale, "build-failed").(string) + "</span>\n" + errOut
|
||||
channelRet["output"] = "<span class='build-error'>" + i18n.Get(locale, "build-error").(string) + "</span>\n" + errOut
|
||||
|
||||
lines := strings.Split(errOut, "\n")
|
||||
|
||||
|
@ -390,8 +386,8 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}(rand.Int())
|
||||
}
|
||||
|
||||
// go install.
|
||||
func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
|
||||
// go test.
|
||||
func GoTestHandler(w http.ResponseWriter, r *http.Request) {
|
||||
data := map[string]interface{}{"succ": true}
|
||||
defer util.RetJSON(w, r, data)
|
||||
|
||||
|
@ -399,11 +395,9 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
|
|||
username := httpSession.Values["username"].(string)
|
||||
locale := conf.Wide.GetUser(username).Locale
|
||||
|
||||
decoder := json.NewDecoder(r.Body)
|
||||
|
||||
var args map[string]interface{}
|
||||
|
||||
if err := decoder.Decode(&args); err != nil {
|
||||
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
|
||||
glog.Error(err)
|
||||
data["succ"] = false
|
||||
|
||||
|
@ -415,8 +409,12 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
|
|||
filePath := args["file"].(string)
|
||||
curDir := filePath[:strings.LastIndex(filePath, conf.PathSeparator)]
|
||||
|
||||
fout, err := os.Create(filePath)
|
||||
cmd := exec.Command("go", "test", "-v")
|
||||
cmd.Dir = curDir
|
||||
|
||||
setCmdEnv(cmd, username)
|
||||
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if nil != err {
|
||||
glog.Error(err)
|
||||
data["succ"] = false
|
||||
|
@ -424,17 +422,108 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
code := args["code"].(string)
|
||||
|
||||
fout.WriteString(code)
|
||||
|
||||
if err := fout.Close(); nil != err {
|
||||
stderr, err := cmd.StderrPipe()
|
||||
if nil != err {
|
||||
glog.Error(err)
|
||||
data["succ"] = false
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if !data["succ"].(bool) {
|
||||
return
|
||||
}
|
||||
|
||||
channelRet := map[string]interface{}{}
|
||||
|
||||
if nil != session.OutputWS[sid] {
|
||||
// 在前端 output 中显示“开始 go test
|
||||
|
||||
channelRet["output"] = "<span class='start-test'>" + i18n.Get(locale, "start-test").(string) + "</span>\n"
|
||||
channelRet["cmd"] = "start-test"
|
||||
|
||||
wsChannel := session.OutputWS[sid]
|
||||
|
||||
err := wsChannel.Conn.WriteJSON(&channelRet)
|
||||
if nil != err {
|
||||
glog.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
// 更新通道最近使用时间
|
||||
wsChannel.Time = time.Now()
|
||||
}
|
||||
|
||||
reader := bufio.NewReader(io.MultiReader(stdout, stderr))
|
||||
|
||||
if err := cmd.Start(); nil != err {
|
||||
glog.Error(err)
|
||||
data["succ"] = false
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
go func(runningId int) {
|
||||
defer util.Recover()
|
||||
|
||||
glog.V(3).Infof("Session [%s] is running [go test] [runningId=%d]", sid, runningId)
|
||||
|
||||
channelRet := map[string]interface{}{}
|
||||
channelRet["cmd"] = "go test"
|
||||
|
||||
// 一次性读取
|
||||
buf, _ := ioutil.ReadAll(reader)
|
||||
|
||||
// 同步点,等待 go test 执行完成
|
||||
cmd.Wait()
|
||||
|
||||
if !cmd.ProcessState.Success() {
|
||||
glog.V(3).Infof("Session [%s] 's running [go test] [runningId=%d] has done (with error)", sid, runningId)
|
||||
|
||||
channelRet["output"] = "<span class='test-error'>" + i18n.Get(locale, "test-error").(string) + "</span>\n" + string(buf)
|
||||
} else {
|
||||
glog.V(3).Infof("Session [%s] 's running [go test] [runningId=%d] has done", sid, runningId)
|
||||
|
||||
channelRet["output"] = "<span class='test-succ'>" + i18n.Get(locale, "test-succ").(string) + "</span>\n" + string(buf)
|
||||
}
|
||||
|
||||
if nil != session.OutputWS[sid] {
|
||||
wsChannel := session.OutputWS[sid]
|
||||
|
||||
err := wsChannel.Conn.WriteJSON(&channelRet)
|
||||
if nil != err {
|
||||
glog.Error(err)
|
||||
}
|
||||
|
||||
// 更新通道最近使用时间
|
||||
wsChannel.Time = time.Now()
|
||||
}
|
||||
}(rand.Int())
|
||||
}
|
||||
|
||||
// go install.
|
||||
func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
|
||||
data := map[string]interface{}{"succ": true}
|
||||
defer util.RetJSON(w, r, data)
|
||||
|
||||
httpSession, _ := session.HTTPSession.Get(r, "wide-session")
|
||||
username := httpSession.Values["username"].(string)
|
||||
locale := conf.Wide.GetUser(username).Locale
|
||||
|
||||
var args map[string]interface{}
|
||||
|
||||
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
|
||||
glog.Error(err)
|
||||
data["succ"] = false
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
sid := args["sid"].(string)
|
||||
|
||||
filePath := args["file"].(string)
|
||||
curDir := filePath[:strings.LastIndex(filePath, conf.PathSeparator)]
|
||||
|
||||
cmd := exec.Command("go", "install")
|
||||
cmd.Dir = curDir
|
||||
|
||||
|
@ -547,7 +636,7 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
channelRet["lints"] = lints
|
||||
|
||||
channelRet["output"] = "<span class='install-failed'>" + i18n.Get(locale, "install-failed").(string) + "</span>\n" + errOut
|
||||
channelRet["output"] = "<span class='install-error'>" + i18n.Get(locale, "install-error").(string) + "</span>\n" + errOut
|
||||
} else {
|
||||
channelRet["output"] = "<span class='install-succ'>" + i18n.Get(locale, "install-succ").(string) + "</span>\n"
|
||||
}
|
||||
|
@ -577,11 +666,9 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
|
|||
username := httpSession.Values["username"].(string)
|
||||
locale := conf.Wide.GetUser(username).Locale
|
||||
|
||||
decoder := json.NewDecoder(r.Body)
|
||||
|
||||
var args map[string]interface{}
|
||||
|
||||
if err := decoder.Decode(&args); err != nil {
|
||||
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
|
||||
glog.Error(err)
|
||||
data["succ"] = false
|
||||
|
||||
|
@ -662,7 +749,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
|
|||
if 0 != len(buf) {
|
||||
glog.V(3).Infof("Session [%s] 's running [go get] [runningId=%d] has done (with error)", sid, runningId)
|
||||
|
||||
channelRet["output"] = "<span class='get-failed'>" + i18n.Get(locale, "get-failed").(string) + "</span>\n" + string(buf)
|
||||
channelRet["output"] = "<span class='get-error'>" + i18n.Get(locale, "get-error").(string) + "</span>\n" + string(buf)
|
||||
} else {
|
||||
glog.V(3).Infof("Session [%s] 's running [go get] [runningId=%d] has done", sid, runningId)
|
||||
|
||||
|
|
|
@ -271,6 +271,7 @@
|
|||
}
|
||||
|
||||
.bottom-window-group .output {
|
||||
font-family: Consolas, Courier New, monospace;
|
||||
padding: 0 5px;
|
||||
line-height: 16px;
|
||||
font-size: 12px;
|
||||
|
@ -281,20 +282,23 @@
|
|||
}
|
||||
|
||||
.bottom-window-group .output .start-build,
|
||||
.bottom-window-group .output .start-test,
|
||||
.bottom-window-group .output .start-install,
|
||||
.bottom-window-group .output .start-get {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.bottom-window-group .output .build-succ,
|
||||
.bottom-window-group .output .build-succ,
|
||||
.bottom-window-group .output .test-succ,
|
||||
.bottom-window-group .output .install-succ,
|
||||
.bottom-window-group .output .get-succ {
|
||||
color: rgb(0,153,0);
|
||||
}
|
||||
|
||||
.bottom-window-group .output .build-failed,
|
||||
.bottom-window-group .output .install-failed,
|
||||
.bottom-window-group .output .get-failed {
|
||||
.bottom-window-group .output .build-error,
|
||||
.bottom-window-group .output .test-error,
|
||||
.bottom-window-group .output .install-error,
|
||||
.bottom-window-group .output .get-error {
|
||||
color: red;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ var editors = {
|
|||
wide.curEditor.focus();
|
||||
},
|
||||
removeAfter: function (id, nextId) {
|
||||
if (id === 'startPage') {
|
||||
if (id === 'startPage') { // 当前关闭的 tab 是起始页
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,10 @@ var editors = {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (editors.data.length === 0) { // 起始页可能存在,所以用编辑器数据判断
|
||||
menu.disabled(['save-all', 'close-all', 'build', 'run', 'go-test', 'go-get', 'go-install']);
|
||||
$(".toolbars").hide();
|
||||
}
|
||||
|
||||
if (!nextId) {
|
||||
// 不存在打开的编辑器
|
||||
|
@ -43,9 +47,6 @@ var editors = {
|
|||
wide.curNode = undefined;
|
||||
|
||||
wide.curEditor = undefined;
|
||||
|
||||
menu.disabled(['save-all', 'close-all', 'run', 'go-get', 'go-install']);
|
||||
$(".toolbars").hide();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -440,7 +441,7 @@ var editors = {
|
|||
content: '<textarea id="editor' + id + '"></textarea>'
|
||||
});
|
||||
|
||||
menu.undisabled(['save-all', 'close-all', 'run', 'go-get', 'go-install']);
|
||||
menu.undisabled(['save-all', 'close-all', 'build', 'run', 'go-test', 'go-get', 'go-install']);
|
||||
|
||||
var rulers = [];
|
||||
rulers.push({color: "#ccc", column: 120, lineStyle: "dashed"});
|
||||
|
|
|
@ -351,11 +351,13 @@ var wide = {
|
|||
|
||||
break;
|
||||
case 'start-build':
|
||||
case 'start-test':
|
||||
case 'start-install':
|
||||
case 'start-get':
|
||||
wide.fillOutput(data.output);
|
||||
|
||||
break;
|
||||
case 'go test':
|
||||
case 'go install':
|
||||
case 'go get':
|
||||
wide.fillOutput($('.bottom-window-group .output > div').html() + data.output);
|
||||
|
@ -541,6 +543,10 @@ var wide = {
|
|||
if (!currentPath) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($(".menu li.build").hasClass("disabled")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var request = newWideRequest();
|
||||
request.file = currentPath;
|
||||
|
@ -600,6 +606,36 @@ var wide = {
|
|||
}
|
||||
});
|
||||
},
|
||||
// 测试.
|
||||
test: function () {
|
||||
wide.saveAllFiles();
|
||||
|
||||
var currentPath = editors.getCurrentPath();
|
||||
if (!currentPath) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($(".menu li.test").hasClass("disabled")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var request = newWideRequest();
|
||||
request.file = currentPath;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/go/test',
|
||||
data: JSON.stringify(request),
|
||||
dataType: "json",
|
||||
beforeSend: function (data) {
|
||||
$('.bottom-window-group .output > div').text('');
|
||||
wide.bottomWindowTab.setCurrent("output");
|
||||
windows.flowBottom();
|
||||
},
|
||||
success: function (data) {
|
||||
}
|
||||
});
|
||||
},
|
||||
goget: function () {
|
||||
wide.saveAllFiles();
|
||||
|
||||
|
@ -643,7 +679,6 @@ var wide = {
|
|||
|
||||
var request = newWideRequest();
|
||||
request.file = currentPath;
|
||||
request.code = wide.curEditor.getValue();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
|
|
|
@ -46,13 +46,17 @@
|
|||
<span>{{.i18n.run}}</span>
|
||||
<div class="frame">
|
||||
<ul>
|
||||
<li class="run disabled" onclick="wide.build()">
|
||||
<li class="build disabled" onclick="wide.build()">
|
||||
<span>{{.i18n.build}}</span>
|
||||
</li>
|
||||
<li class="run disabled" onclick="wide.run()">
|
||||
<span>{{.i18n.build_n_run}}</span>
|
||||
</li>
|
||||
<li class="hr"></li>
|
||||
<li class="go-test disabled" onclick="wide.test()">
|
||||
<span>{{.i18n.test}}</span>
|
||||
</li>
|
||||
<li class="hr"></li>
|
||||
<li class="go-get disabled" onclick="wide.goget()">
|
||||
<span>{{.i18n.goget}}</span>
|
||||
</li>
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (!data.succ) {
|
||||
$("#msg").text('{{.i18n.login_failed}}').show();
|
||||
$("#msg").text('{{.i18n.login_error}}').show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@
|
|||
$("#username").keydown(function (event) {
|
||||
if (event.which === 13) {
|
||||
if ($.trim($(this).val()) === "") {
|
||||
$("#msg").text("{{.i18n.login_failed}}").show();
|
||||
$("#msg").text("{{.i18n.login_error}}").show();
|
||||
} else {
|
||||
$("#password").focus();
|
||||
}
|
||||
|
@ -83,7 +83,7 @@
|
|||
$("#password").keydown(function (event) {
|
||||
if (event.which === 13) {
|
||||
if ($.trim($(this).val()) === "") {
|
||||
$("#msg").text("{{.i18n.login_failed}}").show();
|
||||
$("#msg").text("{{.i18n.login_error}}").show();
|
||||
} else {
|
||||
login();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue