new-service command and manual configuration steps.
Prerequisites
- Development environment set up with
direnv allow - Basic understanding of Go and Protocol Buffers
- Docker Compose or Tilt running (for testing)
Using the new-service Command
Thenew-service command scaffolds a new Go microservice with all the necessary boilerplate.
Generate the service scaffold
Run the command with your service name and optional port:Examples:This creates:
Service names must be in kebab-case (e.g.,
my-service, not MyService or my_service).services/cmd/<service-name>/main.go- Entry pointservices/internal/<service-name>/- Service implementation directorydeploy/docker/<service-name>/Dockerfile.dev- Development Dockerfiledeploy/k8s/<service-name>.nix- Kubernetes manifest moduleproto/<service-name>/v1/<service-name>.proto- Proto definition
Implement your service logic
Add your service implementation in Refer to existing services like
services/internal/<service-name>/service.go.Example structure:services/internal/greeter/service.go for complete examples.Define your proto schema
Edit the generated proto file at Then regenerate code:
proto/<service-name>/v1/<service-name>.proto to define your service contract:Add to docker-compose.yml
Add your service to
docker-compose.yml following the pattern of existing services:Update Tiltfile
Add your service to the 2. Add manifest collection:3. Add go_service call:4. Add k8s_resource configuration:
Tiltfile in multiple places:1. Add to gen-manifests deps:Git add new files (CRITICAL for Nix)
gen-manifests will fail with “file not found” errors.Next Steps
- Add unit tests in
services/internal/<service-name>/service_test.go - Implement observability with OpenTelemetry traces
- Add integration tests if calling other services
- Update frontend to consume your new service
Common Issues
gen-manifests fails with 'file not found'
gen-manifests fails with 'file not found'
You forgot to
git add the new files. Nix requires all files to be in the git tree.buf generate fails
buf generate fails
Check your proto syntax:Ensure
option go_package is correctly set in your .proto file.Service not accessible via Traefik
Service not accessible via Traefik
Verify the PathPrefix in docker-compose.yml matches your proto package exactly:
- Proto:
package myservice.v1; - Service:
service MyServiceService - PathPrefix:
/myservice.v1.MyServiceService
See Also
- Testing Guide - Learn how to test your service
- Debugging Guide - Debug your service in development
- Adding a Node.js Service - Add custom Node.js services