checkstyle for go
Go Makefile
Latest commit d9596bc Jul 29, 2016 @longbai longbai committed on GitHub Merge pull request #14 from buptmiao/master
Report errors when functions miss body
Permalink
Failed to load latest commit information.
gocheckstyle add default config & default dir current directory May 21, 2014
testdata
.gitignore Initial commit Jan 1, 2014
.gostyle self check Mar 30, 2014
.travis.yml
LICENSE Initial commit Jan 1, 2014
Makefile self check Mar 30, 2014
README.md Update README.md Jul 26, 2014
checkstyle.go Report errors when functions miss body Jul 28, 2016
checkstyle_test.go camel name check Mar 16, 2014

README.md

go-checkstyle

Build Status

checkstyle is a style check tool like java checkstyle. This tool inspired by java checkstyle, golint. The style refered to some points in Go Code Review Comments.

to install, run

go get github.com/qiniu/checkstyle/gocheckstyle

to run

gocheckstyle -config=.go_style dir1 dir2

config is json file like 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.xml

Run 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.