From 4db256c9fbbc1ae44a49651e0e205876650ede0b Mon Sep 17 00:00:00 2001 From: Ming Deng Date: Tue, 18 Aug 2020 20:55:11 +0800 Subject: [PATCH] Add git hooks --- CONTRIBUTING.md | 16 ++++++++++++++++ scripts/gobuild.sh => build/gobuild-sample.sh | 0 {scripts => build}/report_build_info.sh | 0 githook/pre-commit | 7 +++++++ 4 files changed, 23 insertions(+) rename scripts/gobuild.sh => build/gobuild-sample.sh (100%) rename {scripts => build}/report_build_info.sh (100%) create mode 100755 githook/pre-commit diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 77adfb65..ee7e0b5a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,6 +7,22 @@ It is the work of hundreds of contributors. We appreciate your help! Here are instructions to get you started. They are probably not perfect, please let us know if anything feels wrong or incomplete. +## Prepare environment + +Firstly, install some tools. Execute those commands **outside** the project. Or those command will modify go.mod file. + +```shell script +go get -u golang.org/x/tools/cmd/goimports + +go get -u github.com/gordonklaus/ineffassign +``` + +And the go into project directory, run : +```shell script +cp ./githook/pre-commit ./.git/hooks/pre-commit +``` +This will add git hooks into .git/hooks. Or you can add it manually. + ## Contribution guidelines ### Pull requests diff --git a/scripts/gobuild.sh b/build/gobuild-sample.sh similarity index 100% rename from scripts/gobuild.sh rename to build/gobuild-sample.sh diff --git a/scripts/report_build_info.sh b/build/report_build_info.sh similarity index 100% rename from scripts/report_build_info.sh rename to build/report_build_info.sh diff --git a/githook/pre-commit b/githook/pre-commit new file mode 100755 index 00000000..594f1edd --- /dev/null +++ b/githook/pre-commit @@ -0,0 +1,7 @@ + +goimports -l pkg +goimports -l examples + +ineffassign . + +staticcheck -show-ignored -checks "-ST1017,-U1000,-ST1005,-S1034,-S1012,-SA4006,-SA6005,-SA1019,-SA1024" ./pkg \ No newline at end of file