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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  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. COMMANDS ?= $(filter-out %.md, $(wildcard ${ROOT_DIR}/server/cmd/*))
  117. BINS ?= $(foreach cmd,${COMMANDS},$(notdir ${cmd}))
  118. ifeq (${COMMANDS},)
  119. $(error Could not determine COMMANDS, set ROOT_DIR or run in source dir)
  120. endif
  121. ifeq (${BINS},)
  122. $(error Could not determine BINS, set ROOT_DIR or run in source dir)
  123. endif
  124. EXCLUDE_TESTS=github.com/OpenIMSDK/OpenKF/test
  125. # ==============================================================================
  126. # Build
  127. ## all: Build all the necessary targets.
  128. .PHONY: all
  129. all: copyright-verify tidy lint cover build
  130. ## build: Build binaries by default.
  131. .PHONY: build
  132. build: # go.build.verify $(addprefix go.build., $(addprefix $(PLATFORM)., $(BINS)))
  133. @echo "===========> Building binary $(BUILDAPP) *[Git Info]: $(VERSION)-$(GIT_COMMIT)"
  134. @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
  135. .PHONY: build.%
  136. build.%:
  137. @echo "$(shell go version)"
  138. @echo "===========> Building binary $(BUILDAPP) *[Git Info]: $(VERSION)-$(GIT_COMMIT)"
  139. @export CGO_ENABLED=0 && GOOS=linux go build -o $(BUILDAPP)/$*/ -ldflags '-s -w' $*/example/$(BUILDFILE)
  140. .PHONY: go.build.verify
  141. go.build.verify:
  142. ifneq ($(shell $(GO) version | grep -q -E '\bgo($(GO_SUPPORTED_VERSIONS))\b' && echo 0 || echo 1), 0)
  143. $(error unsupported go version. Please make install one of the following supported version: '$(GO_SUPPORTED_VERSIONS)')
  144. endif
  145. ## go.build: Build the binary file of the specified platform.
  146. .PHONY: go.build.%
  147. go.build.%:
  148. $(eval COMMAND := $(word 2,$(subst ., ,$*)))
  149. $(eval PLATFORM := $(word 1,$(subst ., ,$*)))
  150. $(eval OS := $(word 1,$(subst _, ,$(PLATFORM))))
  151. $(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM))))
  152. @echo "=====> COMMAND=$(COMMAND)"
  153. @echo "=====> PLATFORM=$(PLATFORM)"
  154. @echo "=====> BIN_DIR=$(BIN_DIR)"
  155. @echo "===========> Building binary $(COMMAND) $(VERSION) for $(OS)_$(ARCH)"
  156. @mkdir -p $(BIN_DIR)/platforms/$(OS)/$(ARCH)
  157. @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)
  158. ## build-multiarch: Build binaries for multiple platforms.
  159. .PHONY: build-multiarch
  160. build-multiarch: go.build.verify $(foreach p,$(PLATFORMS),$(addprefix go.build., $(addprefix $(p)., $(BINS))))
  161. .PHONY: test.junit-report
  162. test.junit-report: tools.verify.go-junit-report
  163. @touch $(TMP_DIR)/coverage.out
  164. @echo "===========> Run unit test > $(TMP_DIR)/report.xml"
  165. # @$(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
  166. @$(GO) test -v -coverprofile=$(TMP_DIR)/coverage.out 2>&1 ./... | $(TOOLS_DIR)/go-junit-report -set-exit-code > $(TMP_DIR)/report.xml
  167. @sed -i '/mock_.*.go/d' $(TMP_DIR)/coverage.out
  168. @echo "===========> Test coverage of Go code is reported to $(TMP_DIR)/coverage.html by generating HTML"
  169. @$(GO) tool cover -html=$(TMP_DIR)/coverage.out -o $(TMP_DIR)/coverage.html
  170. # ==============================================================================
  171. # Targets
  172. SERVER_DIR := server
  173. ## run: Run the server.
  174. .PHONY: run
  175. run:
  176. @echo "===========> Run the server"
  177. @cd $(SERVER_DIR) && $(GO) run main.go
  178. ## tidy: tidy go.mod
  179. .PHONY: tidy
  180. tidy:
  181. @cd $(SERVER_DIR) && $(GO) mod tidy
  182. ## style: Code style -> fmt,vet,lint
  183. .PHONY: style
  184. style: fmt vet lint
  185. ## fmt: Run go fmt against code.
  186. .PHONY: fmt
  187. fmt:
  188. @cd $(SERVER_DIR) && $(GO) fmt ./...
  189. ## vet: Run go vet against code.
  190. .PHONY: vet
  191. vet:
  192. @cd $(SERVER_DIR) && $(GO) vet ./...
  193. ## generate: Run go generate against code and docs.
  194. .PHONY: generate
  195. generate:
  196. @cd $(SERVER_DIR) && $(GO) generate ./...
  197. ## lint: Run go lint against code.
  198. # go1.19+
  199. .PHONY: lint
  200. lint: tools.verify.golangci-lint
  201. @echo "===========> Run golangci to lint source codes"
  202. @cd $(SERVER_DIR) && $(TOOLS_DIR)/golangci-lint run -c $(ROOT_DIR)/.golangci.yml $(ROOT_DIR)/server/...
  203. ## format: Run unit test and format codes
  204. .PHONY: format
  205. format: tools.verify.golines tools.verify.goimports
  206. @echo "===========> Formating codes"
  207. @$(FIND) -type f -name '*.go' | $(XARGS) gofmt -s -w
  208. @$(FIND) -type f -name '*.go' | $(XARGS) $(TOOLS_DIR)/goimports -w -local $(ROOT_PACKAGE)
  209. @$(FIND) -type f -name '*.go' | $(XARGS) $(TOOLS_DIR)/golines -w --max-len=120 --reformat-tags --shorten-comments --ignore-generated .
  210. @cd $(SERVER_DIR) && $(GO) mod edit -fmt
  211. ## updates: Check for updates to go.mod dependencies
  212. .PHONY: updates
  213. updates: tools.verify.go-mod-outdated
  214. @cd $(SERVER_DIR) && $(GO) list -u -m -json all | $(TOOLS_DIR)/go-mod-outdated -update -direct
  215. ## test: Run unit test
  216. .PHONY: test
  217. test:
  218. @cd $(SERVER_DIR) && go test ./...
  219. ## cover: Run unit test with coverage.
  220. .PHONY: cover
  221. cover: test.junit-report
  222. @cd $(SERVER_DIR) && $(GO) tool cover -func=$(TMP_DIR)/coverage.out | \
  223. awk -v target=$(COVERAGE) -f $(ROOT_DIR)/scripts/coverage.awk
  224. ## docker-build: Build docker image with the manager.
  225. .PHONY: docker-build
  226. docker-build: test
  227. docker build --pull --no-cache . -t ${IMG}
  228. ## docker-push: Push docker image with the manager.
  229. .PHONY: docker-push
  230. docker-push:
  231. docker push ${IMG}
  232. ## docker-buildx-push: Push docker image with the manager using buildx.
  233. .PHONY: docker-buildx-push
  234. docker-buildx-push:
  235. docker buildx build -f --pull --no-cache --platform=$(PLATFORMS) --push . -t $(IMG)
  236. ## copyright-verify: Validate boilerplate headers for assign files.
  237. .PHONY: copyright-verify
  238. copyright-verify: tools.verify.addlicense copyright-add
  239. @echo "===========> Validate boilerplate headers for assign files starting in the $(ROOT_DIR) directory"
  240. @$(TOOLS_DIR)/addlicense -v -check -ignore **/server/test/** -f $(LICENSE_TEMPLATE) $(CODE_DIRS)
  241. @echo "===========> End of boilerplate headers check..."
  242. ## copyright-add: Add the boilerplate headers for all files.
  243. .PHONY: copyright-add
  244. copyright-add: tools.verify.addlicense
  245. @echo "===========> Adding $(LICENSE_TEMPLATE) the boilerplate headers for all files"
  246. @$(TOOLS_DIR)/addlicense -y $(shell date +"%Y") -v -c "OpenKF & OpenIM open source community." -f $(LICENSE_TEMPLATE) $(CODE_DIRS)
  247. @echo "===========> End the copyright is added..."
  248. ## swagger: Generate swagger document.
  249. .PHONY: swagger
  250. swagger: tools.verify.swagger
  251. @echo "===========> Generating swagger API docs"
  252. @$(TOOLS_DIR)/swagger generate spec --scan-models -w $(ROOT_DIR)/server/cmd/gendocs -o $(ROOT_DIR)/server/docs/swagger.yaml
  253. ## serve-swagger: Serve swagger spec and docs.
  254. .PHONY: swagger.serve
  255. serve-swagger: tools.verify.swagger
  256. @$(TOOLS_DIR)/swagger serve -F=redoc --no-open --port 36666 $(ROOT_DIR)/server/docs/swagger.yaml
  257. ## release: release the project
  258. .PHONY: release
  259. release: release.verify release.ensure-tag
  260. @scripts/release.sh
  261. ## release.verify: Check if a tool is installed and install it
  262. .PHONY: release.verify
  263. release.verify: tools.verify.git-chglog tools.verify.github-release tools.verify.coscmd tools.verify.coscli
  264. ## release.tag: release the project
  265. .PHONY: release.tag
  266. release.tag: tools.verify.gsemver release.ensure-tag
  267. @git push origin `git describe --tags --abbrev=0`
  268. ## release.ensure-tag: ensure tag
  269. .PHONY: release.ensure-tag
  270. release.ensure-tag: tools.verify.gsemver
  271. @scripts/ensure_tag.sh
  272. ## clean: Clean all builds.
  273. .PHONY: clean
  274. clean:
  275. @echo "===========> Cleaning all builds TMP_DIR($(TMP_DIR)) AND BIN_DIR($(BIN_DIR))"
  276. @-rm -vrf $(TMP_DIR) $(BIN_DIR)
  277. @echo "===========> End clean..."
  278. ## help: Show this help info.
  279. .PHONY: help
  280. help: Makefile
  281. @printf "\n\033[1mUsage: make <TARGETS> ...\033[0m\n\n\\033[1mTargets:\\033[0m\n\n"
  282. @sed -n 's/^##//p' $< | awk -F':' '{printf "\033[36m%-28s\033[0m %s\n", $$1, $$2}' | sed -e 's/^/ /'
  283. ######################################=> common tools<= ############################################
  284. # tools
  285. BUILD_TOOLS ?= go-gitlint golangci-lint goimports addlicense deepcopy-gen conversion-gen ginkgo go-junit-report
  286. ## tools.verify.%: Check if a tool is installed and install it
  287. .PHONY: tools.verify.%
  288. tools.verify.%:
  289. @echo "===========> Verifying $* is installed"
  290. @if [ ! -f $(TOOLS_DIR)/$* ]; then GOBIN=$(TOOLS_DIR) $(MAKE) tools.install.$*; fi
  291. @echo "===========> $* is install in $(TOOLS_DIR)/$*"
  292. # tools: Install a must tools
  293. .PHONY: tools
  294. tools: $(addprefix tools.verify., $(BUILD_TOOLS))
  295. # tools.install.%: Install a single tool in $GOBIN/
  296. .PHONY: tools.install.%
  297. tools.install.%:
  298. @echo "===========> Installing $,The default installation path is $(GOBIN)/$*"
  299. @$(MAKE) install.$*
  300. .PHONY: install.golangci-lint
  301. install.golangci-lint:
  302. @$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
  303. .PHONY: install.goimports
  304. install.goimports:
  305. @$(GO) install golang.org/x/tools/cmd/goimports@latest
  306. .PHONY: install.addlicense
  307. install.addlicense:
  308. @$(GO) install github.com/google/addlicense@latest
  309. .PHONY: install.deepcopy-gen
  310. install.deepcopy-gen:
  311. @$(GO) install k8s.io/code-generator/cmd/deepcopy-gen@latest
  312. .PHONY: install.conversion-gen
  313. install.conversion-gen:
  314. @$(GO) install k8s.io/code-generator/cmd/conversion-gen@latest
  315. .PHONY: install.ginkgo
  316. install.ginkgo:
  317. @$(GO) install github.com/onsi/ginkgo/ginkgo@v1.16.2
  318. # git hook
  319. .PHONY: install.go-gitlint
  320. install.go-gitlint:
  321. @$(GO) install github.com/llorllale/go-gitlint@latest
  322. .PHONY: install.go-junit-report
  323. install.go-junit-report:
  324. @$(GO) install github.com/jstemmer/go-junit-report@latest
  325. ## install.gotests: Install gotests, used to generate go tests
  326. .PHONY: install.swagger
  327. install.swagger:
  328. @$(GO) install github.com/go-swagger/go-swagger/cmd/swagger@latest
  329. # ==============================================================================
  330. # Tools that might be used include go gvm, cos
  331. #
  332. ## install.kube-score: Install kube-score, used to check kubernetes yaml files
  333. .PHONY: install.kube-score
  334. install.kube-score:
  335. @$(GO) install github.com/zegl/kube-score/cmd/kube-score@latest
  336. ## install.kubeconform: Install kubeconform, used to check kubernetes yaml files
  337. .PHONY: install.kubeconform
  338. install.kubeconform:
  339. @$(GO) install github.com/yannh/kubeconform/cmd/kubeconform@latest
  340. ## install.gsemver: Install gsemver, used to generate semver
  341. .PHONY: install.gsemver
  342. install.gsemver:
  343. @$(GO) install github.com/arnaud-deprez/gsemver@latest
  344. ## install.hugo: Install hugo, used to generate website
  345. .PHONY: install.hugo
  346. install.hugo:
  347. @$(GO) install github.com/gohugoio/hugo@latest
  348. ## install.git-chglog: Install git-chglog, used to generate changelog
  349. .PHONY: install.git-chglog
  350. install.git-chglog:
  351. @$(GO) install github.com/git-chglog/git-chglog/cmd/git-chglog@latest
  352. ## install.github-release: Install github-release, used to create github release
  353. .PHONY: install.github-release
  354. install.github-release:
  355. @$(GO) install github.com/github-release/github-release@latest
  356. ## install.goreleaser: Install goreleaser, used to release go program
  357. .PHONY: install.goreleaser
  358. install.goreleaser:
  359. @$(GO) install github.com/goreleaser/goreleaser@latest
  360. ## install.coscli: Install coscli, used to upload files to cos
  361. # example: ./coscli cp/sync -r /root/workspaces/OpenIMSDK/OpenKF/ cos://OpenIMSDK-1306374445/code/ -e cos.ap-hongkong.myqcloud.com
  362. # https://cloud.tencent.com/document/product/436/71763
  363. # OpenIMSDK/*
  364. # - code/
  365. # - docs/
  366. # - images/
  367. # - scripts/
  368. .PHONY: install.coscli
  369. install.coscli:
  370. @wget -q https://github.com/tencentyun/coscli/releases/download/v0.13.0-beta/coscli-linux -O ${TOOLS_DIR}/coscli
  371. @chmod +x ${TOOLS_DIR}/coscli
  372. ## install.coscmd: Install coscmd, used to upload files to cos
  373. .PHONY: install.coscmd
  374. install.coscmd:
  375. @if which pip &>/dev/null; then pip install coscmd; else pip3 install coscmd; fi
  376. ## install.delve: Install delve, used to debug go program
  377. .PHONY: install.delve
  378. install.delve:
  379. @$(GO) install github.com/go-delve/delve/cmd/dlv@latest
  380. ## install.swag: Install swag, used to generate swagger
  381. # go1.17+
  382. # go-swagger is more powerful than swag
  383. # http://localhost:8080/swagger/index.html
  384. .PHONY: install.swag
  385. install.swag:
  386. @$(GO) install github.com/swaggo/swag/cmd/swag@latest
  387. ## install.go-swagger: Install go-swagger, used to generate swagger
  388. .PHONY: install.go-swagger
  389. install.go-swagger:
  390. @$(GO) install github.com/go-swagger/go-swagger/cmd/swagger@latest
  391. ## install.air: Install air, used to hot reload go program
  392. .PHONY: install.air
  393. install.air:
  394. @$(GO) install github.com/cosmtrek/air@latest
  395. ## install.gvm: Install gvm, gvm is a Go version manager, built on top of the official go tool.
  396. .PHONY: install.gvm
  397. install.gvm:
  398. @echo "===========> Installing gvm,The default installation path is ~/.gvm/script/gvm"
  399. @bash < <(curl -s -S -L https://raw.gitee.com/moovweb/gvm/master/binscripts/gvm-installer)
  400. @$(shell source /root/.gvm/script/gvm)
  401. ## install.golines: Install golines, used to format long lines
  402. .PHONY: install.golines
  403. install.golines:
  404. @$(GO) install github.com/segmentio/golines@latest
  405. ## install.go-mod-outdated: Install go-mod-outdated, used to check outdated dependencies
  406. .PHONY: install.go-mod-outdated
  407. install.go-mod-outdated:
  408. @$(GO) install github.com/psampaz/go-mod-outdated@latest
  409. ## install.mockgen: Install mockgen, used to generate mock functions
  410. .PHONY: install.mockgen
  411. install.mockgen:
  412. @$(GO) install github.com/golang/mock/mockgen@latest
  413. ## install.gotests: Install gotests, used to generate test functions
  414. .PHONY: install.gotests
  415. install.gotests:
  416. @$(GO) install github.com/cweill/gotests/gotests@latest
  417. ## install.protoc-gen-go: Install protoc-gen-go, used to generate go source files from protobuf files
  418. .PHONY: install.protoc-gen-go
  419. install.protoc-gen-go:
  420. @$(GO) install github.com/golang/protobuf/protoc-gen-go@latest
  421. ## install.cfssl: Install cfssl, used to generate certificates
  422. .PHONY: install.cfssl
  423. install.cfssl:
  424. @$(ROOT_DIR)/script/install/install.sh iam::install::install_cfssl
  425. ## install.depth: Install depth, used to check dependency tree
  426. .PHONY: install.depth
  427. install.depth:
  428. @$(GO) install github.com/KyleBanks/depth/cmd/depth@latest
  429. ## install.go-callvis: Install go-callvis, used to visualize call graph
  430. .PHONY: install.go-callvis
  431. install.go-callvis:
  432. @$(GO) install github.com/ofabry/go-callvis@latest
  433. ## install.gothanks: Install gothanks, used to thank go dependencies
  434. .PHONY: install.gothanks
  435. install.gothanks:
  436. @$(GO) install github.com/psampaz/gothanks@latest
  437. ## install.richgo: Install richgo
  438. .PHONY: install.richgo
  439. install.richgo:
  440. @$(GO) install github.com/kyoh86/richgo@latest
  441. ## install.rts: Install rts
  442. .PHONY: install.rts
  443. install.rts:
  444. @$(GO) install github.com/galeone/rts/cmd/rts@latest