安装

1.安装protoc二进制文件

  1. 下载地址:https://github.com/google/protobuf/releases
  2. mv bin/protoc /usr/local/bin/
  3. mv -r include/google /usr/local/include/

2.安装protobuf库文件

  1. go get -u github.com/golang/protobuf/proto

3.安装goprotobuf插件

  1. go get github.com/golang/protobuf/protoc-gen-go

4.安装gogoprotobuf插件和依赖

  1. //gogo
  2. go get github.com/gogo/protobuf/protoc-gen-gogo
  3. //gofast
  4. go get github.com/gogo/protobuf/protoc-gen-gofast
  5. //依赖
  6. go get github.com/gogo/protobuf/proto
  7. go get github.com/gogo/protobuf/gogoproto

5.安装框架依赖

  1. # grpc (或者git clone https://github.com/grpc/grpc-go 然后复制到google.golang.org/grpc)
  2. go get -u google.golang.org/grpc
  3. # genproto (或者git clone https://github.com/google/go-genproto 然后复制到google.golang.org/genproto)
  4. go get google.golang.org/genproto/...

6.安装kratos tool

  1. go get -u github.com/go-kratos/kratos/tool/kratos
  2. cd $GOPATH/src
  3. kratos new kratos-demo --proto

7.运行

  1. cd kratos-demo/cmd
  2. go build
  3. ./cmd -conf ../configs

打开浏览器访问:http://localhost:8000/kratos-demo/start,你会看到输出了Golang 大法好 !!!

kratos工具