how to use it

on mac or linux

install go-zero

GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero/tools/goctl;

check

goctl -v

build a project

cd ~;
goctl api new greet;
ls -al;
cd greet;
tree

.
├── etc
│   └── greet-api.yaml
├── greet.api
├── greet.go
└── internal
    ├── config
    │   └── config.go
    ├── handler
    │   ├── greethandler.go
    │   └── routes.go
    ├── logic
    │   └── greetlogic.go
    ├── svc
    │   └── servicecontext.go
    └── types
        └── types.go

modify logic

vim ./internal/logic/greetlogic.go

code

func (l *GreetLogic) Greet(req types.Request) (*types.Response, error) {
    return &types.Response{
        Message: "Hello go-zero",
    }, nil
}

launch app

go run greet.go -f etc/greet-api.yaml

check api

curl -i -X GET \
    http://localhost:8888/from/you