-
中文詳細介紹文檔 https://go-kratos.gitee.io/kratos/#/quickstart
-
本文參考自https://blog.csdn.net/fbbqt/article/details/103872568
-
然后按照官網的教程來搭建的話是很難搭建成功的親測
-
以下是開始之前要准備的環境(最好有梯子沒梯子稍微復雜,然后go環境和環境變量已經配置好)
-
安裝protoc二進制文件
- 下載地址:https://github.com/google/protobuf/releases 這里是win10環境所以選擇win10
- 解壓后選擇你要的文件夾將解壓后的文件添加到環境變量配置
-
代理和mod 設置
- set GO111MODULE=on
- set GOPROXY=https://goproxy.cn/
-
安裝protobuf庫文件
go get -u github.com/golang/protobuf/proto
-
安裝goprotobuf插件
go get github.com/golang/protobuf/protoc-gen-go
-
安裝gogoprotobuf插件和依賴
go get github.com/gogo/protobuf/protoc-gen-gogo
go get github.com/gogo/protobuf/protoc-gen-gofast //依賴 go get github.com/gogo/protobuf/proto go get github.com/gogo/protobuf/gogoproto -
安裝框架依賴
// grpc (或者git clone https://github.com/grpc/grpc-go 然后復制到google.golang.org/grpc)
go get -u google.golang.org/grpc
// genproto (或者git clone https://github.com/google/go-genproto 然后復制到google.golang.org/genproto)go get google.golang.org/genproto/...
-
安裝kratos tool
go get -u github.com/go-kratos/kratos/tool/kratos
-
新建示例
kratos new kratos-demo
-
運行示例
cd kratos-demo kratos run
-
查看http://localhost:8000/kratos-demo/start
官方示例demo地址https://github.com/bilibili/kratos-demo