From 04a4b17c2a45cefc05c1aff989a18afffdec7053 Mon Sep 17 00:00:00 2001 From: Deng Ming Date: Sun, 21 Jan 2024 18:43:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=20go.mod=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .script/goimports.sh | 15 +++++++++++++++ .script/setup.sh | 36 ++++++++++++++++++++++++++++++++++++ Makefile | 28 ++++++++++++++++++++++++++++ go.mod | 3 +++ 4 files changed, 82 insertions(+) create mode 100755 .script/goimports.sh create mode 100755 .script/setup.sh create mode 100644 Makefile create mode 100644 go.mod diff --git a/.script/goimports.sh b/.script/goimports.sh new file mode 100755 index 0000000..a8afc5c --- /dev/null +++ b/.script/goimports.sh @@ -0,0 +1,15 @@ +# Copyright 2021 ecodeclub +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +goimports -l -w $(find . -type f -name '*.go' -not -path "./.idea/*") \ No newline at end of file diff --git a/.script/setup.sh b/.script/setup.sh new file mode 100755 index 0000000..f99d526 --- /dev/null +++ b/.script/setup.sh @@ -0,0 +1,36 @@ +# Copyright 2021 ecodeclub +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SOURCE_COMMIT=.github/pre-commit +TARGET_COMMIT=.git/hooks/pre-commit +SOURCE_PUSH=.github/pre-push +TARGET_PUSH=.git/hooks/pre-push + +# copy pre-commit file if not exist. +echo "设置 git pre-commit hooks..." +cp $SOURCE_COMMIT $TARGET_COMMIT + +# copy pre-push file if not exist. +echo "设置 git pre-push hooks..." +cp $SOURCE_PUSH $TARGET_PUSH + +# add permission to TARGET_PUSH and TARGET_COMMIT file. +test -x $TARGET_PUSH || chmod +x $TARGET_PUSH +test -x $TARGET_COMMIT || chmod +x $TARGET_COMMIT + +echo "安装 golangci-lint..." +go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + +echo "安装 goimports..." +go install golang.org/x/tools/cmd/goimports@latest \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..824788f --- /dev/null +++ b/Makefile @@ -0,0 +1,28 @@ +.PHONY: bench +bench: + @go test -bench=. -benchmem ./... + +.PHONY: ut +ut: + @go test -tags=goexperiment.arenas -race ./... + +.PHONY: setup +setup: + @sh ./.script/setup.sh + +.PHONY: fmt +fmt: + @sh ./.script/goimports.sh + +.PHONY: lint +lint: + @golangci-lint run -c .golangci.yml + +.PHONY: tidy +tidy: + @go mod tidy -v + +.PHONY: check +check: + @$(MAKE) fmt + @$(MAKE) tidy \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..851c08a --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/ecodeclub/grpcx + +go 1.21.5