Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
soar
提交
55e0e8aa
S
soar
项目概览
Xiaomi
/
soar
8 个月 前同步成功
通知
373
Star
8513
Fork
1328
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
soar
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
55e0e8aa
编写于
10月 23, 2018
作者:
martianzhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #4 windows user compatiable
上级
75190193
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
6 deletion
+31
-6
advisor/rules.go
advisor/rules.go
+3
-3
common/config.go
common/config.go
+16
-3
common/config_test.go
common/config_test.go
+12
-0
未找到文件。
advisor/rules.go
浏览文件 @
55e0e8aa
...
...
@@ -115,9 +115,9 @@ func init() {
"OK"
:
{
Item
:
"OK"
,
Severity
:
"L0"
,
Summary
:
"
✔️"
,
// heavy check mark unicode
Content
:
`
✔️
`
,
Case
:
"
✔️
"
,
Summary
:
"
OK"
,
Content
:
`
OK
`
,
Case
:
"
OK
"
,
Func
:
(
*
Query4Audit
)
.
RuleOK
,
},
"ALI.001"
:
{
...
...
common/config.go
浏览文件 @
55e0e8aa
...
...
@@ -26,6 +26,7 @@ import (
"io/ioutil"
"os"
"regexp"
"runtime"
"strings"
"gopkg.in/yaml.v2"
...
...
@@ -120,6 +121,14 @@ type Configration struct {
MaxPrettySQLLength
int
`yaml:"max-pretty-sql-length"`
// 超出该长度的SQL会转换成指纹输出
}
// getDefaultLogOutput get default log-output by runtime.GOOS
func
getDefaultLogOutput
()
string
{
if
runtime
.
GOOS
==
"windows"
{
return
"nul"
}
return
os
.
Stderr
.
Name
()
}
// Config 默认设置
var
Config
=
&
Configration
{
OnlineDSN
:
&
dsn
{
...
...
@@ -158,7 +167,7 @@ var Config = &Configration{
SpaghettiQueryLength
:
2048
,
AllowDropIndex
:
false
,
LogLevel
:
3
,
LogOutput
:
os
.
Stderr
.
Name
(),
LogOutput
:
getDefaultLogOutput
(),
ReportType
:
"markdown"
,
ReportCSS
:
""
,
ReportJavascript
:
""
,
...
...
@@ -538,7 +547,7 @@ func readCmdFlags() error {
maxPrettySQLLength
:=
flag
.
Int
(
"max-pretty-sql-length"
,
Config
.
MaxPrettySQLLength
,
"MaxPrettySQLLength, 超出该长度的SQL会转换成指纹输出"
)
// 一个不存在log-level,用于更新usage。
// 因为vitess里面也用了flag,这些vitess的参数我们不需要关注
if
!
Config
.
Verbose
{
if
!
Config
.
Verbose
&&
runtime
.
GOOS
!=
"windows"
{
flag
.
Usage
=
usage
}
flag
.
Parse
()
...
...
@@ -570,7 +579,11 @@ func readCmdFlags() error {
if
BaseDir
==
""
{
Config
.
LogOutput
=
*
logOutput
}
else
{
Config
.
LogOutput
=
BaseDir
+
"/"
+
*
logOutput
if
runtime
.
GOOS
==
"windows"
{
Config
.
LogOutput
=
*
logOutput
}
else
{
Config
.
LogOutput
=
BaseDir
+
"/"
+
*
logOutput
}
}
}
Config
.
ReportType
=
strings
.
ToLower
(
*
reportType
)
...
...
common/config_test.go
浏览文件 @
55e0e8aa
...
...
@@ -18,6 +18,7 @@ package common
import
(
"flag"
"runtime"
"testing"
"github.com/kr/pretty"
...
...
@@ -25,6 +26,17 @@ import (
var
update
=
flag
.
Bool
(
"update"
,
false
,
"update .golden files"
)
func
TestGetDefaultLogOutput
(
t
*
testing
.
T
)
{
output
:=
getDefaultLogOutput
()
if
runtime
.
GOOS
==
"windows"
&&
output
!=
"nul"
{
t
.
Error
(
"windows default -log-output not nul"
)
}
if
runtime
.
GOOS
!=
"windows"
&&
output
!=
"/dev/stderr"
{
t
.
Error
(
"default -log-output not /dev/stderr"
)
}
}
func
TestParseConfig
(
t
*
testing
.
T
)
{
err
:=
ParseConfig
(
""
)
if
err
!=
nil
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录