- go
- protoc 直接去這裏下 https://github.com/protocolbuffers/protobuf/releases 然後把exe 文件放置到go Path目錄
- protoc-gen-go 直接通過go install 命令進行安裝
- go install github.com/go-kratos/kratos/cmd/kratos/v2@latest
- 這裏會有一些奇葩的path 問題。但是我們不需要關注,如果install命令執行沒有問題既可以使用everyThing 這個軟件加上.exe後綴 查找到build之後的exe文件。把它放置到go Path目錄讓系統可以識別命令即可。
- 還有很多問題都是環境變量導致的。 使用 Get-Command 命令查看當前命令執行的是哪個目錄的exe
- 這裏核心的一個問題是官方提供的makefile 文件中 使用的是gitbash 的find.exe 來替代windos環境的find命令。
- 容易出現文件夾帶空格等一系列問題。 我的解決方案是把git find.exe 在系統中的環境變量優先於 /system32 中的find.exe 這樣就不用擔心find 命令 windows和liunx的差異問題了
-
修改完find的默認執行方式之後就不存在系統的差異了下面這段make 腳本可以直接修改成爲 :
ifeq ($(GOHOSTOS), windows) #the `find.exe` is different from `find` in bash/shell. #to see https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/find. #changed to use git-bash.exe to run find cli or other cli friendly, caused of every developer has a Git. #Git_Bash= $(subst cmd\,bin\bash.exe,$(dir $(shell where git))) Git_Bash=$(subst \,/,$(subst cmd\,bin\bash.exe,$(dir $(shell where git)))) INTERNAL_PROTO_FILES=$(shell $(Git_Bash) -c "find internal -name *.proto") API_PROTO_FILES=$(shell $(Git_Bash) -c "find api -name *.proto") else INTERNAL_PROTO_FILES=$(shell find internal -name *.proto) API_PROTO_FILES=$(shell find api -name *.proto) endif 可以直接修改成爲以下內容 INTERNAL_PROTO_FILES=$(shell find internal -name *.proto) API_PROTO_FILES=$(shell find api -name *.proto)
最後執行make all 進行項目代碼生成 ,途中如果報找不到protc命令 使用go install 安裝對應的命令即可。