Skip to content

Commit 04a4b17

Browse files
committed
初始化 go.mod 文件
1 parent 50d896c commit 04a4b17

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed

.script/goimports.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2021 ecodeclub
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
goimports -l -w $(find . -type f -name '*.go' -not -path "./.idea/*")

.script/setup.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright 2021 ecodeclub
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
SOURCE_COMMIT=.github/pre-commit
16+
TARGET_COMMIT=.git/hooks/pre-commit
17+
SOURCE_PUSH=.github/pre-push
18+
TARGET_PUSH=.git/hooks/pre-push
19+
20+
# copy pre-commit file if not exist.
21+
echo "设置 git pre-commit hooks..."
22+
cp $SOURCE_COMMIT $TARGET_COMMIT
23+
24+
# copy pre-push file if not exist.
25+
echo "设置 git pre-push hooks..."
26+
cp $SOURCE_PUSH $TARGET_PUSH
27+
28+
# add permission to TARGET_PUSH and TARGET_COMMIT file.
29+
test -x $TARGET_PUSH || chmod +x $TARGET_PUSH
30+
test -x $TARGET_COMMIT || chmod +x $TARGET_COMMIT
31+
32+
echo "安装 golangci-lint..."
33+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
34+
35+
echo "安装 goimports..."
36+
go install golang.org/x/tools/cmd/goimports@latest

Makefile

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.PHONY: bench
2+
bench:
3+
@go test -bench=. -benchmem ./...
4+
5+
.PHONY: ut
6+
ut:
7+
@go test -tags=goexperiment.arenas -race ./...
8+
9+
.PHONY: setup
10+
setup:
11+
@sh ./.script/setup.sh
12+
13+
.PHONY: fmt
14+
fmt:
15+
@sh ./.script/goimports.sh
16+
17+
.PHONY: lint
18+
lint:
19+
@golangci-lint run -c .golangci.yml
20+
21+
.PHONY: tidy
22+
tidy:
23+
@go mod tidy -v
24+
25+
.PHONY: check
26+
check:
27+
@$(MAKE) fmt
28+
@$(MAKE) tidy

go.mod

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/ecodeclub/grpcx
2+
3+
go 1.21.5

0 commit comments

Comments
 (0)