From 46acad34002441c36e901fa88d380592924e48e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BC=8A=E6=96=87=E9=BE=99?= Date: Fri, 16 Apr 2021 21:54:31 +0800 Subject: [PATCH] Fix README file of the blog example. (#842) --- examples/blog/README.md | 46 ++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/examples/blog/README.md b/examples/blog/README.md index 9d0c4ce5f..7a7bad615 100644 --- a/examples/blog/README.md +++ b/examples/blog/README.md @@ -1,32 +1,18 @@ -# Kratos Layout - -## Install Kratos +# How to run this blog example server +1. You should ensure that your mysql server is running. +2. Ensure that the database named `testdb` has been created, + otherwise you should execute the following database script: +```mysql +create database testdb; ``` -go get github.com/go-kratos/kratos/cmd/kratos -go get github.com/go-kratos/kratos/cmd/protoc-gen-go-http -go get github.com/go-kratos/kratos/cmd/protoc-gen-go-errors - -# from source -cd cmd/kratos && go install -cd cmd/protoc-gen-go-http && go install -cd cmd/protoc-gen-go-errors && go install -``` -## Create a service -``` -# create project template -kratos new blog - -cd helloworld -# download modules -go mod download - -# generate Proto template -kratos proto add api/blog/blog.proto -# generate Proto source code -kratos proto client api/blog/blog.proto -# generate server template -kratos proto server api/blog/blog.proto -t internal/service态 - -# generate all proto source code, wire, etc. -go generate ./... +3. Modify the `configs/config.yaml` file and add your mysql information in the data source: +```yaml +data: + database: + driver: mysql + source: root:password@tcp(127.0.0.1:3306)/testdb?parseTime=True ``` +4. Run your blog server: +```yaml +make run +``` \ No newline at end of file