Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qiniu/checkstyle
checkstyle for go
https://github.com/qiniu/checkstyle
Last synced: 3 months ago
JSON representation
checkstyle for go
- Host: GitHub
- URL: https://github.com/qiniu/checkstyle
- Owner: qiniu
- License: mit
- Created: 2014-01-01T01:09:27.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2021-03-10T02:55:53.000Z (over 3 years ago)
- Last Synced: 2024-06-18T18:51:53.702Z (5 months ago)
- Language: Go
- Size: 42 KB
- Stars: 129
- Watchers: 12
- Forks: 17
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - checkstyle - checkstyle for go - ★ 85 (Code Analysis)
- awesome-go-extra - checkstyle - 01-01T01:09:27Z|2021-03-10T02:55:53Z| (Code Analysis / Routers)
README
go-checkstyle
=============
[![Build Status](https://api.travis-ci.org/qiniu/checkstyle.png?branch=master)](https://travis-ci.org/qiniu/checkstyle)checkstyle is a style check tool like java checkstyle. This tool inspired by [java checkstyle](https://github.com/checkstyle/checkstyle), [golint](https://github.com/golang/lint). The style refered to some points in [Go Code Review Comments](https://code.google.com/p/go-wiki/wiki/CodeReviewComments).
# Install
go get github.com/qiniu/checkstyle/gocheckstyle# Run
gocheckstyle -config=.go_style dir1 dir2# Config
config is json file like the following:
```
{
"file_line": 500,
"func_line": 50,
"params_num":4,
"results_num":3,
"formated": true,
"pkg_name": true,
"camel_name":true,
"ignore":[
"a/*",
"b/*/c/*.go"
],
"fatal":[
"formated"
]
}```
# Add to makefile
```
check_go_style:
bash -c "mkdir -p checkstyle; cd checkstyle && export GOPATH=`pwd` && go get github.com/qiniu/checkstyle/gocheckstyle"
checkstyle/bin/gocheckstyle -config=.go_style dir1 dir2```
# Integrate with jenkins checkstyle plugin
excute in shell
```
mkdir -p checkstyle; cd checkstyle && export GOPATH=`pwd` && go get github.com/qiniu/checkstyle/gocheckstyle"
checkstyle/bin/gocheckstyle -reporter=xml -config=.go_style dir1 dir2 2>gostyle.xml
```
then add postbuild checkstyle file gostyle.xmlRun checkstyle with one or more filenames or directories. The output of this tool is a list of suggestions. If you need to force obey the rule, place it in fatal.
# Checkstyle's difference with other tools
Checkstyle differs from gofmt. Gofmt reformats Go source code, whereas checkstyle prints out coding style suggestion.Checkstyle differs from golint. Checkstyle check file line/function line/param number, could be configed by user.