update readme

master
kevin 4 years ago
parent befdaab542
commit 5821b7324e

@ -89,13 +89,11 @@ go get -u github.com/tal-tech/go-zero
## 6. Quick Start
0. 完整示例请查看[从0到1快速构建一个高并发的微服务系统](doc/shorturl.md)
0. 完整示例请查看
1. 编译goctl工具
[从0到1快速构建一个高并发的微服务系统](doc/shorturl.md)
```shell
go build tools/goctl/goctl.go
```
1. 从[这里](https://github.com/tal-tech/go-zero/releases)下载goctl工具
把goctl放到$PATH的目录下确保goctl可执行
@ -135,7 +133,7 @@ go get -u github.com/tal-tech/go-zero
```
├── greet
│   ├── etc
│   │   └── greet-api.json // 配置文件
│   │   └── greet-api.yaml // 配置文件
│   ├── greet.go // main文件
│   └── internal
│   ├── config
@ -155,15 +153,21 @@ go get -u github.com/tal-tech/go-zero
```shell
cd greet
go run greet.go -f etc/greet-api.json
go run greet.go -f etc/greet-api.yaml
```
默认侦听在8888端口可以在配置文件里修改可以通过curl请求
```shell
➜ go-zero git:(master) curl -w "\ncode: %{http_code}\n" http://localhost:8888/greet/from/kevin
{"code":0}
code: 200
curl -i http://localhost:8888/greet/from/you
```
返回如下:
```http
HTTP/1.1 200 OK
Date: Sun, 30 Aug 2020 15:32:35 GMT
Content-Length: 0
```
编写业务代码:

@ -5,6 +5,6 @@ build:
mac:
GOOS=darwin go build -ldflags="-s -w" -ldflags="-X 'main.BuildTime=$(version)'" -o goctl-darwin goctl.go
win:
GOOS=windows go build -ldflags="-s -w" -ldflags="-X 'main.BuildTime=$(version)'" -o goctl-windows goctl.go
GOOS=windows go build -ldflags="-s -w" -ldflags="-X 'main.BuildTime=$(version)'" -o goctl.exe goctl.go
linux:
GOOS=linux go build -ldflags="-s -w" -ldflags="-X 'main.BuildTime=$(version)'" -o goctl-linux goctl.go

Loading…
Cancel
Save