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 tidyAfter 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/pingIf it returns
{"message":"pong"}, it works.
Note
hz new is only used to initialize the project, use hz update to update the project.
See using protobuf and use thrift.
Last modified
October 11, 2023
: chore: fix link error (#814) (056e58b82b)