MyGoland 首次提交:Go 轻量 IDE
- 编辑器:多标签、语法高亮、gopls 全套(补全/诊断/跳转/重命名/代码动作/内联提示/签名大纲) - 调试:Delve DAP(断点/条件断点/变量树/表达式求值/goroutine 列表) - 测试:结果树、覆盖率行着色、失败跳源码、-run 精确运行、行号可跑标记 - Git:状态着色、选择性暂存提交、pull/push、历史并排对比 - 本地历史 + 自动快照 + 崩溃恢复、会话/光标恢复 - 全局搜索替换(预览+确认,GBK 安全)、多终端、gopls 崩溃自愈 - 设计文档与验证记录见 docs/plans/
This commit is contained in:
commit
a80c0f886a
220 files changed
+20784
No files matched your search
@@ -0,0 +1,44 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// logMaxSize 是日志文件的上限,超过则在启动时清空重来。
|
||||
const logMaxSize = 4 << 20
|
||||
|
||||
// logPath 是当前日志文件路径,为空表示没启用文件日志。
|
||||
var logPath string
|
||||
|
||||
// SetupLog 把日志同时写到用户缓存目录与标准错误。
|
||||
//
|
||||
// GUI 子系统(-H=windowsgui)下没有控制台,标准错误是无效句柄,
|
||||
// 所以必须落文件,否则语言服务器与调试的排错信息全丢。
|
||||
func SetupLog() string {
|
||||
dir, err := os.UserCacheDir()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
dir = filepath.Join(dir, "mygoland")
|
||||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||
return ""
|
||||
}
|
||||
p := filepath.Join(dir, "mygoland.log")
|
||||
if st, err := os.Stat(p); err == nil && st.Size() > logMaxSize {
|
||||
_ = os.Remove(p)
|
||||
}
|
||||
f, err := os.OpenFile(p, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o644)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
log.SetFlags(log.LstdFlags | log.Lmicroseconds)
|
||||
log.SetOutput(io.MultiWriter(f, os.Stderr))
|
||||
logPath = p
|
||||
return p
|
||||
}
|
||||
|
||||
// LogPath 返回日志文件路径。
|
||||
func LogPath() string { return logPath }
|
||||
Reference in new issue
Block a user