You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 19 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. # Copyright 2023 OpenIMSDK. All rights reserved.
  2. # Use of this source code is governed by a MIT style
  3. # license that can be found in the LICENSE file.
  4. ###################################=> common commands <=#############################################
  5. # ========================== Capture Environment ===============================
  6. # get the repo root and output path
  7. ROOT_PACKAGE=github.com/OpenIMSDK/OpenKF
  8. OUT_DIR=$(REPO_ROOT)/_output
  9. # ==============================================================================
  10. # define the default goal
  11. #
  12. SHELL := /bin/bash
  13. DIRS=$(shell ls)
  14. GO=go
  15. .DEFAULT_GOAL := help
  16. # include the common makefile
  17. COMMON_SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
  18. # ROOT_DIR: root directory of the code base
  19. ifeq ($(origin ROOT_DIR),undefined)
  20. ROOT_DIR := $(abspath $(shell cd $(COMMON_SELF_DIR)/. && pwd -P))
  21. endif
  22. # OUTPUT_DIR: The directory where the build output is stored.
  23. ifeq ($(origin OUTPUT_DIR),undefined)
  24. OUTPUT_DIR := $(ROOT_DIR)/_output
  25. $(shell mkdir -p $(OUTPUT_DIR))
  26. endif
  27. # BIN_DIR: The directory where the build output is stored.
  28. ifeq ($(origin BIN_DIR),undefined)
  29. BIN_DIR := $(OUTPUT_DIR)/bin
  30. $(shell mkdir -p $(BIN_DIR))
  31. endif
  32. ifeq ($(origin TOOLS_DIR),undefined)
  33. TOOLS_DIR := $(OUTPUT_DIR)/tools
  34. $(shell mkdir -p $(TOOLS_DIR))
  35. endif
  36. ifeq ($(origin TMP_DIR),undefined)
  37. TMP_DIR := $(OUTPUT_DIR)/tmp
  38. $(shell mkdir -p $(TMP_DIR))
  39. endif
  40. ifeq ($(origin VERSION), undefined)
  41. VERSION := $(shell git describe --tags --always --match="v*" --dirty | sed 's/-/./g') #v2.3.3.631.g00abdc9b.dirty
  42. endif
  43. # Check if the tree is dirty. default to dirty(maybe u should commit?)
  44. GIT_TREE_STATE:="dirty"
  45. ifeq (, $(shell git status --porcelain 2>/dev/null))
  46. GIT_TREE_STATE="clean"
  47. endif
  48. GIT_COMMIT:=$(shell git rev-parse HEAD)
  49. # Image URL to use all building/pushing image targets
  50. IMG ?= openim/openkf:test
  51. BUILDFILE = "./main.go"
  52. BUILDAPP = "$(OUTPUT_DIR)/"
  53. # Define the directory you want to copyright
  54. CODE_DIRS := $(ROOT_DIR)/.github $(ROOT_DIR)/server $(ROOT_DIR)/scripts $(ROOT_DIR)/build $(ROOT_DIR)/web $(ROOT_DIR)/kf_plugins
  55. FINDS := find $(CODE_DIRS)
  56. ifndef V
  57. MAKEFLAGS += --no-print-directory
  58. endif
  59. # The OS must be linux when building docker images
  60. PLATFORMS ?= linux_s390x linux_mips64 linux_mips64le darwin_amd64 windows_amd64 linux_amd64 linux_arm64 linux_ppc64le
  61. # Set a specific PLATFORM
  62. ifeq ($(origin PLATFORM), undefined)
  63. ifeq ($(origin GOOS), undefined)
  64. GOOS := $(shell go env GOOS)
  65. endif
  66. ifeq ($(origin GOARCH), undefined)
  67. GOARCH := $(shell go env GOARCH)
  68. endif
  69. PLATFORM := $(GOOS)_$(GOARCH)
  70. # Use linux as the default OS when building images
  71. IMAGE_PLAT := linux_$(GOARCH)
  72. else
  73. GOOS := $(word 1, $(subst _, ,$(PLATFORM)))
  74. GOARCH := $(word 2, $(subst _, ,$(PLATFORM)))
  75. IMAGE_PLAT := $(PLATFORM)
  76. endif
  77. # Copy githook scripts when execute makefile
  78. # TODO! GIT_FILE_SIZE_LIMIT=42000000 git commit -m "This commit is allowed file sizes up to 42MB"
  79. COPY_GITHOOK:=$(shell cp -f scripts/githooks/* .git/hooks/; chmod +x .git/hooks/*)
  80. # Linux command settings
  81. FIND := find . ! -path './image/*' ! -path './vendor/*' ! -path './bin/*'
  82. XARGS := xargs -r
  83. # ==============================================================================
  84. # TODO: License selection
  85. # LICENSE_TEMPLATE ?= $(ROOT_DIR)/scripts/LICENSE/license_templates.txt # MIT License
  86. LICENSE_TEMPLATE ?= $(ROOT_DIR)/scripts/LICENSE/LICENSE_TEMPLATES # Apache License
  87. # COMMA: Concatenate multiple strings to form a list of strings
  88. COMMA := ,
  89. # SPACE: Used to separate strings
  90. SPACE :=
  91. # SPACE: Replace multiple consecutive Spaces with a single space
  92. SPACE +=
  93. # ==============================================================================
  94. # Build definition
  95. GO_SUPPORTED_VERSIONS ?= 1.18|1.19|1.20
  96. GO_LDFLAGS += -X $(VERSION_PACKAGE).GitVersion=$(VERSION) \
  97. -X $(VERSION_PACKAGE).GitCommit=$(GIT_COMMIT) \
  98. -X $(VERSION_PACKAGE).GitTreeState=$(GIT_TREE_STATE) \
  99. -X $(VERSION_PACKAGE).BuildDate=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
  100. ifneq ($(DLV),)
  101. GO_BUILD_FLAGS += -gcflags "all=-N -l"
  102. LDFLAGS = ""
  103. endif
  104. GO_BUILD_FLAGS += -ldflags "$(GO_LDFLAGS)"
  105. # The use of make for Windows is not recommended
  106. ifeq ($(GOOS),windows)
  107. GO_OUT_EXT := .exe
  108. endif
  109. ifeq ($(ROOT_PACKAGE),)
  110. $(error the variable ROOT_PACKAGE must be set prior to including golang.mk)
  111. endif
  112. GOPATH := $(shell go env GOPATH)
  113. ifeq ($(origin GOBIN), undefined)
  114. GOBIN := $(GOPATH)/bin
  115. endif
  116. ifeq ($(OS),Windows_NT)
  117. NULL :=
  118. SPACE := $(NULL) $(NULL)
  119. ROOT_DIR := $(subst $(SPACE),\$(SPACE),$(shell cd))
  120. else
  121. ROOT_DIR := $(shell pwd)
  122. endif
  123. COMMANDS := $(filter-out %.md, $(wildcard $(ROOT_DIR)/server/cmd/*))
  124. BINS := $(notdir $(COMMANDS))
  125. ifeq ($(strip $(COMMANDS)),)
  126. $(error Could not determine COMMANDS, set ROOT_DIR or run in source dir)
  127. endif
  128. ifeq ($(strip $(BINS)),)
  129. $(error Could not determine BINS, set ROOT_DIR or run in source dir)
  130. endif
  131. EXCLUDE_TESTS=github.com/OpenIMSDK/OpenKF/test
  132. # ==============================================================================
  133. # Build
  134. ## all: Build all the necessary targets.
  135. .PHONY: all
  136. all: copyright-verify tidy lint cover build
  137. ## build: Build binaries by default.
  138. .PHONY: build
  139. build: # go.build.verify $(addprefix go.build., $(addprefix $(PLATFORM)., $(BINS)))
  140. @echo "===========> Building binary $(BUILDAPP) *[Git Info]: $(VERSION)-$(GIT_COMMIT)"
  141. @cd $(SERVER_DIR) && CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o $(BIN_DIR)/platforms/openkf $(ROOT_DIR)/server/main.go
  142. .PHONY: build.%
  143. build.%:
  144. @echo "$(shell go version)"
  145. @echo "===========> Building binary $(BUILDAPP) *[Git Info]: $(VERSION)-$(GIT_COMMIT)"
  146. @cd $(SERVER_DIR) && export CGO_ENABLED=0 && GOOS=linux go build -o $(BUILDAPP)/$*/ -ldflags '-s -w' $*/example/$(BUILDFILE)
  147. .PHONY: go.build.verify
  148. go.build.verify:
  149. ifneq ($(shell $(GO) version | grep -q -E '\bgo($(GO_SUPPORTED_VERSIONS))\b' && echo 0 || echo 1), 0)
  150. $(error unsupported go version. Please make install one of the following supported version: '$(GO_SUPPORTED_VERSIONS)')
  151. endif
  152. ## go.build: Build the binary file of the specified platform.
  153. .PHONY: go.build.%
  154. go.build.%:
  155. $(eval COMMAND := $(word 2,$(subst ., ,$*)))
  156. $(eval PLATFORM := $(word 1,$(subst ., ,$*)))
  157. $(eval OS := $(word 1,$(subst _, ,$(PLATFORM))))
  158. $(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM))))
  159. @cd $(SERVER_DIR)
  160. @echo "=====> COMMAND=$(COMMAND)"
  161. @echo "=====> PLATFORM=$(PLATFORM)"
  162. @echo "=====> BIN_DIR=$(BIN_DIR)"
  163. @echo "===========> Building binary $(COMMAND) $(VERSION) for $(OS)_$(ARCH)"
  164. @mkdir -p $(BIN_DIR)/platforms/$(OS)/$(ARCH)
  165. @CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o $(BIN_DIR)/platforms/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT) $(ROOT_PACKAGE)/cmd/$(COMMAND)
  166. ## build-multiarch: Build binaries for multiple platforms.
  167. .PHONY: build-multiarch
  168. build-multiarch: go.build.verify $(foreach p,$(PLATFORMS),$(addprefix go.build., $(addprefix $(p)., $(BINS))))
  169. .PHONY: test.junit-report
  170. test.junit-report: tools.verify.go-junit-report
  171. @touch $(TMP_DIR)/coverage.out
  172. @cd $(SERVER_DIR)
  173. @echo "===========> Run unit test > $(TMP_DIR)/report.xml"
  174. # @$(GO) test -v -coverprofile=$(TMP_DIR)/coverage.out 2>&1 $(GO_BUILD_FLAGS) ./... | $(TOOLS_DIR)/go-junit-report -set-exit-code > $(TMP_DIR)/report.xml
  175. @$(GO) test -v -coverprofile=$(TMP_DIR)/coverage.out 2>&1 ./... | $(TOOLS_DIR)/go-junit-report -set-exit-code > $(TMP_DIR)/report.xml
  176. @sed -i '/mock_.*.go/d' $(TMP_DIR)/coverage.out
  177. @echo "===========> Test coverage of Go code is reported to $(TMP_DIR)/coverage.html by generating HTML"
  178. @$(GO) tool cover -html=$(TMP_DIR)/coverage.out -o $(TMP_DIR)/coverage.html
  179. # ==============================================================================
  180. # Targets
  181. SERVER_DIR := server
  182. ## run: Run the server.
  183. .PHONY: run
  184. run:
  185. @echo "===========> Run the server"
  186. @cd $(SERVER_DIR) && $(GO) run main.go
  187. ## tidy: tidy go.mod
  188. .PHONY: tidy
  189. tidy:
  190. @cd $(SERVER_DIR) && $(GO) mod tidy
  191. ## style: Code style -> fmt,vet,lint
  192. .PHONY: style
  193. style: fmt vet lint
  194. ## fmt: Run go fmt against code.
  195. .PHONY: fmt
  196. fmt:
  197. @cd $(SERVER_DIR) && $(GO) fmt ./...
  198. ## vet: Run go vet against code.
  199. .PHONY: vet
  200. vet:
  201. @cd $(SERVER_DIR) && $(GO) vet ./...
  202. ## generate: Run go generate against code and docs.
  203. .PHONY: generate
  204. generate:
  205. @cd $(SERVER_DIR) && $(GO) generate ./...
  206. ## lint: Run go lint against code.
  207. # go1.19+
  208. .PHONY: lint
  209. lint: tools.verify.golangci-lint
  210. @echo "===========> Run golangci to lint source codes"
  211. @cd $(SERVER_DIR) && $(TOOLS_DIR)/golangci-lint run -c $(ROOT_DIR)/.golangci.yml $(ROOT_DIR)/server/...
  212. ## format: Run unit test and format codes
  213. .PHONY: format
  214. format: tools.verify.golines tools.verify.goimports
  215. @echo "===========> Formating codes"
  216. @$(FIND) -type f -name '*.go' | $(XARGS) gofmt -s -w
  217. @$(FIND) -type f -name '*.go' | $(XARGS) $(TOOLS_DIR)/goimports -w -local $(ROOT_PACKAGE)
  218. @$(FIND) -type f -name '*.go' | $(XARGS) $(TOOLS_DIR)/golines -w --max-len=200 --reformat-tags --shorten-comments --ignore-generated .
  219. @cd $(SERVER_DIR) && $(GO) mod edit -fmt
  220. ## updates: Check for updates to go.mod dependencies
  221. .PHONY: updates
  222. updates: tools.verify.go-mod-outdated
  223. @cd $(SERVER_DIR) && $(GO) list -u -m -json all | $(TOOLS_DIR)/go-mod-outdated -update -direct
  224. ## test: Run unit test
  225. .PHONY: test
  226. test:
  227. @cd $(SERVER_DIR) && go test ./...
  228. ## cover: Run unit test with coverage.
  229. .PHONY: cover
  230. cover: test.junit-report
  231. @cd $(SERVER_DIR) && $(GO) tool cover -func=$(TMP_DIR)/coverage.out | \
  232. awk -v target=$(COVERAGE) -f $(ROOT_DIR)/scripts/coverage.awk
  233. ## docker-build: Build docker image with the manager.
  234. .PHONY: docker-build
  235. docker-build: test
  236. docker build --pull --no-cache . -t ${IMG}
  237. ## docker-push: Push docker image with the manager.
  238. .PHONY: docker-push
  239. docker-push:
  240. docker push ${IMG}
  241. ## docker-buildx-push: Push docker image with the manager using buildx.
  242. .PHONY: docker-buildx-push
  243. docker-buildx-push:
  244. docker buildx build -f --pull --no-cache --platform=$(PLATFORMS) --push . -t $(IMG)
  245. ## copyright-verify: Validate boilerplate headers for assign files.
  246. .PHONY: copyright-verify
  247. copyright-verify: tools.verify.addlicense copyright-add
  248. @echo "===========> Validate boilerplate headers for assign files starting in the $(ROOT_DIR) directory"
  249. @$(TOOLS_DIR)/addlicense -v -check -ignore **/server/test/** -f $(LICENSE_TEMPLATE) $(CODE_DIRS)
  250. @echo "===========> End of boilerplate headers check..."
  251. ## copyright-add: Add the boilerplate headers for all files.
  252. .PHONY: copyright-add
  253. copyright-add: tools.verify.addlicense
  254. @echo "===========> Adding $(LICENSE_TEMPLATE) the boilerplate headers for all files"
  255. @$(TOOLS_DIR)/addlicense -y $(shell date +"%Y") -v -c "OpenKF & OpenIM open source community." -f $(LICENSE_TEMPLATE) $(CODE_DIRS)
  256. @echo "===========> End the copyright is added..."
  257. ## swagger: Generate swagger document.
  258. .PHONY: swagger
  259. swagger: tools.verify.swagger
  260. @echo "===========> Generating swagger API docs"
  261. @$(TOOLS_DIR)/swagger generate spec --scan-models -w $(ROOT_DIR)/server/cmd/gendocs -o $(ROOT_DIR)/server/docs/swagger.yaml
  262. ## serve-swagger: Serve swagger spec and docs.
  263. .PHONY: swagger.serve
  264. serve-swagger: tools.verify.swagger
  265. @$(TOOLS_DIR)/swagger serve -F=redoc --no-open --port 36666 $(ROOT_DIR)/server/docs/swagger.yaml
  266. ## release: release the project
  267. .PHONY: release
  268. release: release.verify release.ensure-tag
  269. @scripts/release.sh
  270. ## release.verify: Check if a tool is installed and install it
  271. .PHONY: release.verify
  272. release.verify: tools.verify.git-chglog tools.verify.github-release tools.verify.coscmd tools.verify.coscli
  273. ## release.tag: release the project
  274. .PHONY: release.tag
  275. release.tag: tools.verify.gsemver release.ensure-tag
  276. @git push origin `git describe --tags --abbrev=0`
  277. ## release.ensure-tag: ensure tag
  278. .PHONY: release.ensure-tag
  279. release.ensure-tag: tools.verify.gsemver
  280. @scripts/ensure_tag.sh
  281. ## clean: Clean all builds.
  282. .PHONY: clean
  283. clean:
  284. @echo "===========> Cleaning all builds TMP_DIR($(TMP_DIR)) AND BIN_DIR($(BIN_DIR))"
  285. @-rm -vrf $(TMP_DIR) $(BIN_DIR)
  286. @echo "===========> End clean..."
  287. ## help: Show this help info.
  288. .PHONY: help
  289. help: Makefile
  290. @printf "\n\033[1mUsage: make <TARGETS> ...\033[0m\n\n\\033[1mTargets:\\033[0m\n\n"
  291. @sed -n 's/^##//p' $< | awk -F':' '{printf "\033[36m%-28s\033[0m %s\n", $$1, $$2}' | sed -e 's/^/ /'
  292. ######################################=> common tools<= ############################################
  293. # tools
  294. BUILD_TOOLS ?= go-gitlint golangci-lint goimports addlicense deepcopy-gen conversion-gen ginkgo go-junit-report
  295. ## tools.verify.%: Check if a tool is installed and install it
  296. .PHONY: tools.verify.%
  297. tools.verify.%:
  298. @echo "===========> Verifying $* is installed"
  299. @if [ ! -f $(TOOLS_DIR)/$* ]; then GOBIN=$(TOOLS_DIR) $(MAKE) tools.install.$*; fi
  300. @echo "===========> $* is install in $(TOOLS_DIR)/$*"
  301. # tools: Install a must tools
  302. .PHONY: tools
  303. tools: $(addprefix tools.verify., $(BUILD_TOOLS))
  304. # tools.install.%: Install a single tool in $GOBIN/
  305. .PHONY: tools.install.%
  306. tools.install.%:
  307. @echo "===========> Installing $,The default installation path is $(GOBIN)/$*"
  308. @$(MAKE) install.$*
  309. .PHONY: install.golangci-lint
  310. install.golangci-lint:
  311. @$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
  312. .PHONY: install.goimports
  313. install.goimports:
  314. @$(GO) install golang.org/x/tools/cmd/goimports@latest
  315. .PHONY: install.addlicense
  316. install.addlicense:
  317. @$(GO) install github.com/google/addlicense@latest
  318. .PHONY: install.deepcopy-gen
  319. install.deepcopy-gen:
  320. @$(GO) install k8s.io/code-generator/cmd/deepcopy-gen@latest
  321. .PHONY: install.conversion-gen
  322. install.conversion-gen:
  323. @$(GO) install k8s.io/code-generator/cmd/conversion-gen@latest
  324. .PHONY: install.ginkgo
  325. install.ginkgo:
  326. @$(GO) install github.com/onsi/ginkgo/ginkgo@v1.16.2
  327. # git hook
  328. .PHONY: install.go-gitlint
  329. install.go-gitlint:
  330. @$(GO) install github.com/llorllale/go-gitlint@latest
  331. .PHONY: install.go-junit-report
  332. install.go-junit-report:
  333. @$(GO) install github.com/jstemmer/go-junit-report@latest
  334. ## install.gotests: Install gotests, used to generate go tests
  335. .PHONY: install.swagger
  336. install.swagger:
  337. @$(GO) install github.com/go-swagger/go-swagger/cmd/swagger@latest
  338. # ==============================================================================
  339. # Tools that might be used include go gvm, cos
  340. #
  341. ## install.kube-score: Install kube-score, used to check kubernetes yaml files
  342. .PHONY: install.kube-score
  343. install.kube-score:
  344. @$(GO) install github.com/zegl/kube-score/cmd/kube-score@latest
  345. ## install.kubeconform: Install kubeconform, used to check kubernetes yaml files
  346. .PHONY: install.kubeconform
  347. install.kubeconform:
  348. @$(GO) install github.com/yannh/kubeconform/cmd/kubeconform@latest
  349. ## install.gsemver: Install gsemver, used to generate semver
  350. .PHONY: install.gsemver
  351. install.gsemver:
  352. @$(GO) install github.com/arnaud-deprez/gsemver@latest
  353. ## install.hugo: Install hugo, used to generate website
  354. .PHONY: install.hugo
  355. install.hugo:
  356. @$(GO) install github.com/gohugoio/hugo@latest
  357. ## install.git-chglog: Install git-chglog, used to generate changelog
  358. .PHONY: install.git-chglog
  359. install.git-chglog:
  360. @$(GO) install github.com/git-chglog/git-chglog/cmd/git-chglog@latest
  361. ## install.github-release: Install github-release, used to create github release
  362. .PHONY: install.github-release
  363. install.github-release:
  364. @$(GO) install github.com/github-release/github-release@latest
  365. ## install.goreleaser: Install goreleaser, used to release go program
  366. .PHONY: install.goreleaser
  367. install.goreleaser:
  368. @$(GO) install github.com/goreleaser/goreleaser@latest
  369. ## install.coscli: Install coscli, used to upload files to cos
  370. # example: ./coscli cp/sync -r /root/workspaces/OpenIMSDK/OpenKF/ cos://OpenIMSDK-1306374445/code/ -e cos.ap-hongkong.myqcloud.com
  371. # https://cloud.tencent.com/document/product/436/71763
  372. # OpenIMSDK/*
  373. # - code/
  374. # - docs/
  375. # - images/
  376. # - scripts/
  377. .PHONY: install.coscli
  378. install.coscli:
  379. @wget -q https://github.com/tencentyun/coscli/releases/download/v0.13.0-beta/coscli-linux -O ${TOOLS_DIR}/coscli
  380. @chmod +x ${TOOLS_DIR}/coscli
  381. ## install.coscmd: Install coscmd, used to upload files to cos
  382. .PHONY: install.coscmd
  383. install.coscmd:
  384. @if which pip &>/dev/null; then pip install coscmd; else pip3 install coscmd; fi
  385. ## install.delve: Install delve, used to debug go program
  386. .PHONY: install.delve
  387. install.delve:
  388. @$(GO) install github.com/go-delve/delve/cmd/dlv@latest
  389. ## install.swag: Install swag, used to generate swagger
  390. # go1.17+
  391. # go-swagger is more powerful than swag
  392. # http://localhost:8080/swagger/index.html
  393. .PHONY: install.swag
  394. install.swag:
  395. @$(GO) install github.com/swaggo/swag/cmd/swag@latest
  396. ## install.go-swagger: Install go-swagger, used to generate swagger
  397. .PHONY: install.go-swagger
  398. install.go-swagger:
  399. @$(GO) install github.com/go-swagger/go-swagger/cmd/swagger@latest
  400. ## install.air: Install air, used to hot reload go program
  401. .PHONY: install.air
  402. install.air:
  403. @$(GO) install github.com/cosmtrek/air@latest
  404. ## install.gvm: Install gvm, gvm is a Go version manager, built on top of the official go tool.
  405. .PHONY: install.gvm
  406. install.gvm:
  407. @echo "===========> Installing gvm,The default installation path is ~/.gvm/script/gvm"
  408. @bash < <(curl -s -S -L https://raw.gitee.com/moovweb/gvm/master/binscripts/gvm-installer)
  409. @$(shell source /root/.gvm/script/gvm)
  410. ## install.golines: Install golines, used to format long lines
  411. .PHONY: install.golines
  412. install.golines:
  413. @$(GO) install github.com/segmentio/golines@latest
  414. ## install.go-mod-outdated: Install go-mod-outdated, used to check outdated dependencies
  415. .PHONY: install.go-mod-outdated
  416. install.go-mod-outdated:
  417. @$(GO) install github.com/psampaz/go-mod-outdated@latest
  418. ## install.mockgen: Install mockgen, used to generate mock functions
  419. .PHONY: install.mockgen
  420. install.mockgen:
  421. @$(GO) install github.com/golang/mock/mockgen@latest
  422. ## install.gotests: Install gotests, used to generate test functions
  423. .PHONY: install.gotests
  424. install.gotests:
  425. @$(GO) install github.com/cweill/gotests/gotests@latest
  426. ## install.protoc-gen-go: Install protoc-gen-go, used to generate go source files from protobuf files
  427. .PHONY: install.protoc-gen-go
  428. install.protoc-gen-go:
  429. @$(GO) install github.com/golang/protobuf/protoc-gen-go@latest
  430. ## install.cfssl: Install cfssl, used to generate certificates
  431. .PHONY: install.cfssl
  432. install.cfssl:
  433. @$(ROOT_DIR)/script/install/install.sh iam::install::install_cfssl
  434. ## install.depth: Install depth, used to check dependency tree
  435. .PHONY: install.depth
  436. install.depth:
  437. @$(GO) install github.com/KyleBanks/depth/cmd/depth@latest
  438. ## install.go-callvis: Install go-callvis, used to visualize call graph
  439. .PHONY: install.go-callvis
  440. install.go-callvis:
  441. @$(GO) install github.com/ofabry/go-callvis@latest
  442. ## install.gothanks: Install gothanks, used to thank go dependencies
  443. .PHONY: install.gothanks
  444. install.gothanks:
  445. @$(GO) install github.com/psampaz/gothanks@latest
  446. ## install.richgo: Install richgo
  447. .PHONY: install.richgo
  448. install.richgo:
  449. @$(GO) install github.com/kyoh86/richgo@latest
  450. ## install.rts: Install rts
  451. .PHONY: install.rts
  452. install.rts:
  453. @$(GO) install github.com/galeone/rts/cmd/rts@latest