Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
b1b87474
M
milvus
项目概览
milvus
/
milvus
12 个月 前同步成功
通知
261
Star
22476
Fork
2472
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b1b87474
编写于
12月 29, 2020
作者:
Q
quicksilver
提交者:
yefu.chen
12月 29, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add logic of incremental check for go code
Signed-off-by:
N
quicksilver
<
zhifeng.zhang@zilliz.com
>
上级
24334624
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
60 addition
and
9 deletion
+60
-9
Makefile
Makefile
+10
-0
githooks/pre-commit/fmt
githooks/pre-commit/fmt
+2
-0
internal/proxy/validate_util.go
internal/proxy/validate_util.go
+1
-1
internal/proxy/validate_util_test.go
internal/proxy/validate_util_test.go
+1
-1
scripts/gofmt.sh
scripts/gofmt.sh
+46
-7
未找到文件。
Makefile
浏览文件 @
b1b87474
...
...
@@ -39,10 +39,15 @@ check-proto-product: generated-proto-go
@
(
env
bash
$(PWD)
/scripts/check_proto_product.sh
)
fmt
:
ifdef
GO_DIFF_FILES
@
echo
"Running
$@
check"
@
GO111MODULE
=
on
env
bash
$(PWD)
/scripts/gofmt.sh
$(GO_DIFF_FILES)
else
@
echo
"Running
$@
check"
@
GO111MODULE
=
on
env
bash
$(PWD)
/scripts/gofmt.sh cmd/
@
GO111MODULE
=
on
env
bash
$(PWD)
/scripts/gofmt.sh internal/
@
GO111MODULE
=
on
env
bash
$(PWD)
/scripts/gofmt.sh tests/go/
endif
#TODO: Check code specifications by golangci-lint
lint
:
...
...
@@ -53,10 +58,15 @@ lint:
@
GO111MODULE
=
on
${GOPATH}
/bin/golangci-lint run
--timeout
=
30m
--config
./.golangci.yml ./tests/go/...
ruleguard
:
ifdef
GO_DIFF_FILES
@
echo
"Running
$@
check"
@
${GOPATH}
/bin/ruleguard
-rules
ruleguard.rules.go
$(GO_DIFF_FILES)
else
@
echo
"Running
$@
check"
@
${GOPATH}
/bin/ruleguard
-rules
ruleguard.rules.go ./internal/...
@
${GOPATH}
/bin/ruleguard
-rules
ruleguard.rules.go ./cmd/...
@
${GOPATH}
/bin/ruleguard
-rules
ruleguard.rules.go ./tests/go/...
endif
verifiers
:
getdeps cppcheck fmt lint ruleguard
...
...
githooks/pre-commit/fmt
浏览文件 @
b1b87474
#! /bin/bash
export
GO_DIFF_FILES
=
$(
git diff
--name-only
--diff-filter
=
d HEAD
"*.go"
)
make
fmt
internal/proxy/validate_util.go
浏览文件 @
b1b87474
...
...
@@ -130,7 +130,7 @@ func ValidateDimension(dim int64, isBinary bool) error {
}
func
ValidateVectorFieldMetricType
(
field
*
schemapb
.
FieldSchema
)
error
{
if
field
.
DataType
!=
schemapb
.
DataType_VECTOR_FLOAT
{
if
(
field
.
DataType
!=
schemapb
.
DataType_VECTOR_FLOAT
)
&&
(
field
.
DataType
!=
schemapb
.
DataType_VECTOR_BINARY
)
{
return
nil
}
for
_
,
params
:=
range
field
.
IndexParams
{
...
...
internal/proxy/validate_util_test.go
浏览文件 @
b1b87474
...
...
@@ -107,7 +107,7 @@ func TestValidateVectorFieldMetricType(t *testing.T) {
field1
.
DataType
=
schemapb
.
DataType_VECTOR_FLOAT
assert
.
NotNil
(
t
,
ValidateVectorFieldMetricType
(
field1
))
field1
.
IndexParams
=
[]
*
commonpb
.
KeyValuePair
{
&
commonpb
.
KeyValuePair
{
{
Key
:
"abcdefg"
,
Value
:
""
,
},
...
...
scripts/gofmt.sh
浏览文件 @
b1b87474
#!/usr/bin/env bash
SCRIPTS_DIR
=
"
$(
cd
-P
"
$(
dirname
"
$SOURCE
"
)
"
&&
pwd
)
"
## green to echo
function
green
(){
echo
-e
"
\0
33[32m
$1
\0
33[0m"
}
GO_SRC_DIR
=
"
${
SCRIPTS_DIR
}
/
$1
"
if
test
-z
"
$(
gofmt
-d
$GO_SRC_DIR
)
"
;
then
exit
0
## Error
function
bred
(){
echo
-e
"
\0
33[31m
\0
33[01m
$1
\0
33[0m"
}
files
=()
files_need_gofmt
=()
if
[
-f
"
$1
"
]
;
then
files+
=(
"
$1
"
)
fi
if
[
-d
"
$1
"
]
;
then
for
file
in
`
find
$1
-type
f |
grep
"
\.
go$"
`
;
do
files+
=(
"
$file
"
)
done
fi
# Check for files that fail gofmt.
if
[[
"
${#
files
[@]
}
"
-ne
0
]]
;
then
for
file
in
"
${
files
[@]
}
"
;
do
diff
=
"
$(
gofmt
-s
-d
${
file
}
2>&1
)
"
if
[[
-n
"
$diff
"
]]
;
then
files_need_gofmt+
=(
"
${
file
}
"
)
fi
done
fi
if
[[
"
${#
files_need_gofmt
[@]
}
"
-ne
0
]]
;
then
bred
"ERROR!"
for
file
in
"
${
files_need_gofmt
[@]
}
"
;
do
gofmt
-s
-d
${
file
}
2>&1
done
echo
""
bred
"Some files have not been gofmt'd. To fix these errors, "
bred
"copy and paste the following:"
for
file
in
"
${
files_need_gofmt
[@]
}
"
;
do
bred
" gofmt -s -w
${
file
}
"
done
exit
1
else
gofmt
-d
$GO_SRC_DIR
echo
"Please format your code by gofmt!"
exit
1
green
"OK"
exit
0
fi
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录