在windows 環境下Kratos 代碼示例搭建


  • 中文詳細介紹文檔  https://go-kratos.gitee.io/kratos/#/quickstart

  • 本文參考自https://blog.csdn.net/fbbqt/article/details/103872568

  • 然后按照官網的教程來搭建的話是很難搭建成功的親測

  • 以下是開始之前要准備的環境(最好有梯子沒梯子稍微復雜,然后go環境和環境變量已經配置好)

  • 安裝protoc二進制文件

  • 代理和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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM