-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Add gometalinter errcheck to pre-commit-hook, fix all Go unchecked errors. #2885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
d7adc54 to
08e7d2a
Compare
wangkuiyi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool change!
paddle/scripts/travis/check_style.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who would call check_style.sh?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. I see. I recommended to call check_style.sh from Travis CI.
wangkuiyi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
3c78242 to
beae398
Compare
.pre-commit-config.yaml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用了gometalinter应该就不用再单独使用golint了。
https://github.com/alecthomas/gometalinter#quickstart
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gongweibao done.
paddle/scripts/travis/check_style.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是做什么?是测试代码?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe @helinwang wants to listing the directory to log file. That's reasonable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gongweibao @dzhwinter 不好意思,是测试的,不知为何在我本地能运行,在travis不行,加了写代码测试了一下。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gongweibao @dzhwinter all removed, found the issue:
go tool的对象代码(比如go build xxx)最好是在$GOPATH里面,不然会有各种问题(vendor directory ignored, no caching of built object files...)。我是调travis gometalinter的时候出现的这个问题,如果运行对象不在$GOPATH中,gometalinter一直过不了。改成了这样才过的:https://github.com/PaddlePaddle/pre-commit-golang/blob/master/run-gometalinter.sh#L5
paddle/scripts/travis/check_style.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cd go; gometalinter --vendor --disable-all --enable=errcheck --enable=golint ./... ; cd -
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我们是否也把vet检查加上?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gongweibao go vet 有一些正确的地方过不了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the message showing go vet fails:
gometalinter --vendor --disable-all --enable errcheck --enable vet --enable golint ./...
master/c/client.go:26::error: possible misuse of unsafe.Pointer (vet)
pserver/optimizer.go:17::error: possible misuse of unsafe.Pointer (vet)
pserver/client/c/cclient.go:37::error: possible misuse of unsafe.Pointer (vet)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gongweibao , 修复了,其实go vet都报对了。加上go vet了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
dzhwinter
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
go/pserver/service.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a smart feature of named return value!
seems that I ignored so much return error when saving the checkpoint.
paddle/scripts/travis/check_style.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe @helinwang wants to listing the directory to log file. That's reasonable.
paddle/scripts/travis/check_style.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to filter out the vendor package file. change to
find ./go -not -path "./go/vendor/*"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dzhwinter good point! Please see https://github.com/PaddlePaddle/pre-commit-golang/blob/master/run-gometalinter.sh , --vendor already ignore the vendor folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get it.
Unchecked errors could be handled by: cd go; gometalinter --vendor --disable-all --enable errcheck $(glide nv)
faa803b to
c791f90
Compare
gongweibao
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.