From 5821b7324e67250541a2176cafd5f7afec37f777 Mon Sep 17 00:00:00 2001 From: kevin Date: Sun, 30 Aug 2020 23:34:57 +0800 Subject: [PATCH] update readme --- readme.md | 26 +++++++++++++++----------- tools/goctl/Makefile | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/readme.md b/readme.md index 741e213e..becc1765 100644 --- a/readme.md +++ b/readme.md @@ -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 @@ -152,18 +150,24 @@ go get -u github.com/tal-tech/go-zero └── greet.api // api描述文件 ``` 生成的代码可以直接运行: - + ```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 ``` 编写业务代码: diff --git a/tools/goctl/Makefile b/tools/goctl/Makefile index 859d5325..f4b34408 100644 --- a/tools/goctl/Makefile +++ b/tools/goctl/Makefile @@ -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