Skip to content

Commit

Permalink
初始化 go.mod 文件
Browse files Browse the repository at this point in the history
  • Loading branch information
flycash committed Jan 21, 2024
1 parent 50d896c commit 04a4b17
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .script/goimports.sh
Original file line number Diff line number Diff line change
@@ -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/*")
36 changes: 36 additions & 0 deletions .script/setup.sh
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/ecodeclub/grpcx

go 1.21.5

0 comments on commit 04a4b17

Please sign in to comment.