hz basic usage
hz basic usage.
Basic Usage
new: Create a new Hertz project
-
Create a new project
# Execute outside GOPATH, you need to specify the go mod name hz new -module hertz/demo # Tidy & get dependencies go mod tidy
# Execute under GOPATH, go mod name defaults to the current path relative to GOPATH, or you can specify your own hz new # Tidy & get dependencies go mod init # `go.mod` will not be generated after the previous step executed under GOPATH. go mod tidy
After executed, it generates a scaffold for the Hertz project in the current directory.
-
Compiling Projects
go build
-
Run the project and test it
Run the project:
./{{your binary}}
Test:
curl 127.0.0.1:8888/ping
If it returns
{"message":"pong"}
, it works.
Notes
After creating a project with hz new
, you can use the IDL file to write the project interface, and use the hz update
series of commands to update the project code.
See Using protobuf and use thrift.
Last modified
September 23, 2023
: docs: update hz usage document (dec0b93)