Edit code → Deploy to Cloud Run (2 min) → Test → It's broken → Fix → Deploy again (2 min) → ...
↑ ↑
WASTED 2 MINUTES! WASTED ANOTHER 2 MINUTES!
Result: 5-10 minutes wasted on a simple bug that takes 2 seconds to fix locally.
✅ CORRECT WORKFLOW:
1. Edit code
2. Test locally (2 seconds)
3. Fix any issues locally
4. ONLY deploy when it works locally
5. Test on Cloud Run
❌ WRONG WORKFLOW:
1. Edit code
2. Deploy immediately (2 minutes)
3. Find it's broken
4. Go back to step 1
# Terminal 1: Start emulator (keep running)
make emulator
# Terminal 2: Run server
make dev-game
# Terminal 3: Test
curl http://localhost:8080/
curl -X POST http://localhost:8080/games/create- Tested homepage locally
- Tested all changed endpoints locally
- Checked logs for errors
- Verified template renders correctly
- Made at least one successful test request
ONLY THEN: make deploy-game
Edit → Test locally (2s) → Fix → Test (2s) → Repeat until working → Deploy once
Edit → Deploy (2min) → Test → Fix → Deploy (2min) → Test → ...
git add -A
git commit -m "WIP: testing template fix" # Local commit
# Test more
git commit -m "Fix template rendering" # Local commit
# Test again, it works!
git push # Push when donegit commit -m "try fix 1" && git push
# Deploy, test, broken
git commit -m "try fix 2" && git push
# Deploy, test, broken
git commit -m "try fix 3" && git push
# Result: messy git history, wasted time# Make request
curl http://localhost:8080/games/test
# Check logs immediately
# Look for → handler entry, ✓ success, ✗ errors
# See which template rendered
# See any error messages# Make request
curl http://localhost:8080/games/test
# It shows wrong page
# Immediately start changing code without checking logs
# Waste time guessing what's wrongWhen you spend >10 minutes on something (like template inheritance), document:
- What you tried
- Why it didn't work
- What the solution was
- Better alternatives
Example: We created TEMPLATE-OPTIONS.md after fighting with html/template.
- Spending >30 minutes on something basic
- Writing lots of boilerplate
- Fighting with the stdlib
- Templates: Use
templorgomponents - Routing: Use
chi(we already did this!) - Validation: Use
validator - Database: Use an ORM if SQL gets messy
But also:
- Don't deploy drunk
- Test locally first (see Rule #1)
- Document your brilliant ideas before you forget them
Edit CSS → Kill server → Wait 2s → Restart → Test → Repeat
Edit CSS/HTML → Refresh browser (instant!) → Done
Templates reload on every request in dev mode:
func reloadTemplatesInDev() {
if os.Getenv("ENV") != "production" {
templates = template.Must(template.ParseGlob("views/*.html"))
}
}Called at the start of every handler that uses templates.
- Go code changes (handlers, models, logic)
- Dependency changes (go.mod)
- Template changes (HTML, CSS in
<style>, JavaScript in<script>) - Just refresh your browser!
The One Rule to Rule Them All:
Test locally. Deploy once. Save time.
Time Savings:
Without local dev: 10-20 minutes per feature (multiple deploys) With local dev: 2-5 minutes per feature (one deploy)
4x faster development!