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.
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
September 23, 2024
: Revert "chore: add 9.21 beijing meetup to zh homepage" (#1152) (5e9509f)