Use this skill to initialize a new Go backend project using go-zero framework. It follows the directory structure and coding standards from odds-center. Supports "initialize go-zero project", "create go-zero backend", "setup new go project".
This skill guides the AI to initialize a new Go backend project using the go-zero framework, following the pattern of the odds-center reference project.
Ask the user for the following information if not already provided:
bingo or github.com/my/repo)user-service)Execute the following commands to create the standard directory structure:
# Create root directories
mkdir -p api/etc
mkdir -p common-service/entity
mkdir -p common-service/svc
mkdir -p infra/cache
mkdir -p infra/cfg
mkdir -p infra/convertx
mkdir -p infra/middleware
mkdir -p infra/timex
mkdir -p internal/handler
mkdir -p internal/logic
mkdir -p internal/model
mkdir -p internal/types
mkdir -p internal/svc
mkdir -p internal/config
mkdir -p etc
mkdir -p target
Use the copy_from_template pattern (conceptually) by reading the templates from skills/go-zero-backend-init/templates/ and writing them to the project root, replacing variables.
Variables to Replace:
{{MODULE_NAME}}: The Go module name (e.g., bingo){{SERVICE_NAME}}: The service name (e.g., user-service)Files to Generate:
go.mod
templates/go.mod.tmplgo.mod{{MODULE_NAME}} with module name.Makefile
templates/Makefile.tmplMakefile{{SERVICE_NAME}} if applicable.Config (etc/{{SERVICE_NAME}}.yaml)
templates/config.yaml.tmpletc/{{SERVICE_NAME}}.yamlMain File ({{SERVICE_NAME}}.go)
templates/main.go.tmpl{{SERVICE_NAME}}.go{{MODULE_NAME}}, {{SERVICE_NAME}}.Service Context (internal/svc/service_context.go)
templates/svc.go.tmplinternal/svc/service_context.go{{MODULE_NAME}}.Config Struct (internal/config/config.go)
templates/config_struct.go.tmplinternal/config/config.go{{MODULE_NAME}}.go mod tidy to download dependencies.The templates are located in the templates/ subdirectory of this skill.
For detailed code patterns, refer to:
references/code-templates.md (Logic, Handler, Model patterns)references/config-examples.md (YAML config examples)