Project Initialization
Template Introduction
A template is a predefined set of code structures that provides the basic architecture and engineering standards for a project.
Templates help you quickly start initializing a project without writing code from scratch.
Template Types
jzero provides the following types of templates to meet various scenarios:
- Built-in template(frame): Built-in template providing core framework capabilities, supports optional features (database/cache)
- Path template(home): Specify a path as a template, usually placed inside a specific project to meet specific project needs
- Local template(local): Local global template located in ~/.jzero/templates/local folder
- Remote repository template(remote+branch): Can be used to build enterprise-specific remote template repositories
For detailed usage, see: Template Guide
Template market
If built-in frames such as api, rpc, and gateway are not enough, visit the jzero Template Market.
The template market is the entry for discovering built-in templates, official external templates, and third-party templates. You can use it to quickly find the source repository, usage guide, and recommended initialization command for a template.
For official external templates, jzero new usually only needs the --branch parameter because the default remote repository already points to https://github.com/jzero-io/templates.
Quick links:
# Official CLI template
jzero new mycli --branch cli
# Official Vercel API template
jzero new myvercel --branch api-vercel
# Third-party or private template
jzero new your_project --remote <template-repo> --branch <template-branch>For more template details and examples, see the jzero Template Market and Template Guide.
Initialize api project
jzero new your_project --frame api
cd your_project
# download dependencies
go mod tidy
# start server
go run main.go server
# visit swagger ui
http://localhost:8001/swaggerdocker run --rm -v ${PWD}:/app ghcr.io/jzero-io/jzero:latest new your_project --frame api
cd your_project
# download dependencies
go mod tidy
# start server
go run main.go server
# visit swagger ui
http://localhost:8001/swaggerInitialize rpc project
jzero new your_project --frame rpc
cd your_project
# download dependencies
go mod tidy
# start server
go run main.go serverdocker run --rm -v ${PWD}:/app ghcr.io/jzero-io/jzero:latest new your_project --frame rpc
cd your_project
# download dependencies
go mod tidy
# start server
go run main.go serverInitialize gateway project
Supports both grpc/http interfaces
jzero new your_project --frame gateway
cd your_project
# download dependencies
go mod tidy
# start server
go run main.go server
# visit swagger ui
http://localhost:8001/swaggerdocker run --rm -v ${PWD}:/app ghcr.io/jzero-io/jzero:latest new your_project --frame gateway
cd your_project
# download dependencies
go mod tidy
# start server
go run main.go server
# visit swagger ui
http://localhost:8001/swaggerOptional features model/redis/model+redis
Based on optional features, provides a complete solution for using model/redis/model
# Use case: need to connect to relational database(model) with database cache(cache), redis
jzero new your_project --features model,cache,redis
# Use case: need to connect to relational database(model), redis
jzero new your_project --features model,redis
# Use case: need to connect to relational database(model) with database cache(cache)
jzero new your_project --features model,cache
# Use case: need to connect to relational database(model)
jzero new your_project --features model