Skip to content

Commit

Permalink
Merge pull request #44 from yusank/feature/v1
Browse files Browse the repository at this point in the history
Feature/v1
  • Loading branch information
yusank authored May 21, 2022
2 parents 3b9a65a + e4ae5c5 commit 9df360a
Show file tree
Hide file tree
Showing 137 changed files with 19,889 additions and 1,013 deletions.
78 changes: 61 additions & 17 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,71 @@ run:
- third_party
- tests
skip-dirs-use-default: true
timeout: 5m
linters:
disable-all: true # 关闭其他linter
enable: # 下面是开启的linter列表,之后的英文注释介绍了相应linter的功能
- deadcode # Finds unused code
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
- gosimple # Linter for Go source code that specializes in simplifying a code
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
- ineffassign # Detects when assignments to existing variables are not used
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
- structcheck # Finds unused struct fields
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
- unused # Checks Go code for unused constants, variables, functions and types
- varcheck # Finds unused global variables and constants
# - scopelint # Scopelint checks for unpinned variables in go programs
- exportloopref
# - golint # Carry out the stylistic conventions put forth in Effective Go and CodeReviewComments
- revive
disable:
- gochecknoglobals
- funlen
# 1.22+
- wsl
- godox
- gocognit
- nolintlint
- testpackage
- noctx
- nlreturn
- gosimple
- gomnd
- goerr113
- exhaustive
- nestif
- stylecheck
- godot
- gofumpt
- whitespace
- unparam
- gci
- gochecknoinits
enable:
- asciicheck
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
- errcheck
- exportloopref
- goconst
- gocritic
- gocyclo
- gofmt
- goheader
- goimports
- golint
- gomodguard
- goprintffuncname
- gosec
- govet
- ineffassign
- interfacer
- lll
- misspell
- prealloc
- rowserrcheck
- scopelint
- sqlclosecheck
- staticcheck
- structcheck
- typecheck
- unconvert
- unused
- varcheck

linters-settings:
govet: # 对于linter govet,我们手动开启了它的某些扫描规则
check-shadowing: true
check-unreachable: true
check-rangeloops: true
check-copylocks: true
check-copylocks: true
lll:
line-length: 140
46 changes: 36 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,32 @@ SHELL:=/usr/bin/env bash
.DEFAULT_GOAL:=help

Srv ?= push
BinPath ?= bin/$(Srv)
BinPath ?= bin/service.goim.$(Srv)
CmdPath ?= apps/$(Srv)/cmd/main.go
CfgPath ?= apps/$(Srv)/config
ProtoFile ?= api/config/v1/config.proto
CfgPath ?= apps/$(Srv)/configs
IMAGE ?= goim/$(Srv)
VERSION ?= $(shell git describe --exact-match --tags 2> /dev/null || git rev-parse --abbrev-ref HEAD)

## env
export ROCKETMQ_GO_LOG_LEVEL=warn

## jwt
export JWT_SECRET="goim"

##################################################
# Development #
##################################################

##@ Development

.PHONY: vet
vet: ## Run go vet against code.
go vet -v ./...

.PHONY: lint
lint: ## Run go lint against code.
golangci-lint run ./... -v

.PHONY: vet
vet: ## Run go vet against code.
go vet -v ./...

.PHONEY: test
test: ## Run test against code.
go test -v ./...
Expand All @@ -37,9 +39,14 @@ test: ## Run test against code.

##@ Generate

.PHONY: protoc
protoc: ## Run protoc command to generate pb code.
protoc -I. --go_out=. --go-grpc_out=. $(ProtoFile)
.PHONY: gen-protoc
gen-protoc: ## Run protoc command to generate pb code.
# call gen_proto.sh
./gen_proto.sh api

.PHONY: tools-install
tools-install: ## Install tools.
go get -u github.com/golang/protobuf/protoc-gen-go

##################################################
# Build #
Expand All @@ -56,6 +63,7 @@ build-all: ## build all apps
make build Srv=push
make build Srv=gateway
make build Srv=msg
make build Srv=user
##################################################
# Docker #
##################################################
Expand All @@ -78,6 +86,24 @@ docker-build: ## build docker image
run: build ## run provided server
./$(BinPath) --conf $(CfgPath)

.PHONY: run-all
run-all: build-all ## run all apps
nohup make run Srv=push > push.stderr.log 2>&1 & \
nohup make run Srv=gateway > gateway.stderr.log 2>&1 & \
nohup make run Srv=msg > msg.stderr.log 2>&1 & \
nohup make run Srv=user > user.stderr.log 2>&1 &

.PHONY: stop
stop: ## stop all apps
ps -ef | grep -v grep | grep 'service.goim' | awk '{print $$2}' | xargs kill -15

.PHONY: restart
restart: stop run-all

.PHONY: swagger
swagger: ## generate swagger file
go generate ./... && go run swagger.go

##################################################
# General #
##################################################
Expand Down
74 changes: 40 additions & 34 deletions api/config/registry/v1/registry.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9df360a

Please sign in to comment.