https://github.com/yowenter/go-micro-example
The go-micro service example for tutorial
https://github.com/yowenter/go-micro-example
Last synced: 9 months ago
JSON representation
The go-micro service example for tutorial
- Host: GitHub
- URL: https://github.com/yowenter/go-micro-example
- Owner: yowenter
- Created: 2020-02-13T06:02:01.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-25T14:44:13.000Z (almost 6 years ago)
- Last Synced: 2025-02-15T20:49:51.863Z (11 months ago)
- Language: Go
- Size: 28.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go micro example
## 配置环境变量
```bash
source env.sh
```
## 安装依赖
```bash
go get github.com/micro/protoc-gen-micro/v2 # 在 bin 目录下会有 protoc-gen-micro
go get -u github.com/golang/protobuf/protoc-gen-go # 在 bin 目录下会有 protoc-gen-go
go get github.com/micro/go-micro # 下载 go micro 服务框架,下载完在 pkg 目录下会有一吨东西
```
## 生成 proto pb go 文件
```bash
protoc --plugin=protoc-gen-go=$GOPATH/bin/protoc-gen-go --plugin=protoc-gen-micro=$GOPATH/bin/protoc-gen-micro --proto_path=$GOPATH/src/wuu.com/example/hello:. --micro_out=$GOPATH/src/wuu.com/example/hello --go_out=$GOPATH/src/wuu.com/example/hello $GOPATH/src/wuu.com/example/hello/hello.proto
```
```bash
cd src/wuu.com/example
go mod init
go run server/server.go # 启动 server
go run client/client.go # 在新的 terminal 启动 客户端
```
## 清除 go mod 缓存
```bash
go clean -modcache
```