Thank you for your interest in contributing examples!
mkdir my-example
cd my-examplemodule my-example
go 1.25
require github.com/livetemplate/livetemplate v0.1.0
// If using E2E tests:
// require github.com/livetemplate/lvt v0.1.0package main
import (
"log"
"net/http"
lt "github.com/livetemplate/livetemplate"
)
func main() {
// Your example code
}Create my-example/README.md explaining:
- What the example demonstrates
- How to run it
- Key features
- Any prerequisites
Use Chromedp for browser-based E2E tests:
package main
import (
"testing"
lvttest "github.com/livetemplate/lvt/testing"
)
func TestMyExample(t *testing.T) {
// Your E2E test
}Add your example to the main README.md with:
- Example name and description
- Directory path
- How to run
- Key features
- Follow Go best practices
- Add comments for complex logic
- Handle errors properly
- Use meaningful variable names
- Clear README in example directory
- Code comments explaining key concepts
- Step-by-step setup instructions
- Add E2E tests using Chromedp
- Test happy paths and edge cases
- Verify UI updates correctly
- Test WebSocket communication
- Use CDN version for production examples
- Reference client library version in comments
- Show both CDN and local dev setup
- Minimize external dependencies
- Use standard library when possible
- Document any required dependencies
If you need to test your example against unreleased core library or LVT changes, you have two options:
The easiest way - Go automatically uses local modules without any go.mod changes:
# From parent directory containing all repos
cd ..
./setup-workspace.sh
# Now test examples with local core library and LVT
cd examples
./test-all.sh # Uses local livetemplate + lvt
# Or test individual example
cd counter
go test -v # Automatically uses ../livetemplate and ../lvtThe workspace setup is done once and affects all repositories. See the core library CONTRIBUTING.md for details.
If you prefer manual control:
# Enable local development mode for all examples
./scripts/setup-local-dev.sh
# Test with local libraries
./test-all.sh
# Revert to published versions
./scripts/setup-local-dev.sh --undoDirectory structure for both methods:
parent/
├── livetemplate/ (core library)
├── lvt/ (CLI tool)
└── examples/ (this repo)
# Run the example
cd my-example
go run main.go
# Run E2E tests
go test -v
# Test all examples together
cd ..
./test-all.sh- Fork the repository
- Create a branch:
git checkout -b example/my-example - Add your example
- Update main README.md
- Test thoroughly
- Commit:
git commit -m "Add my-example demonstrating X" - Push:
git push origin example/my-example - Create Pull Request
Consider these categories for new examples:
- Basic: Simple concepts (counter, hello world)
- CRUD: Database operations
- Real-time: WebSocket, chat, collaboration
- Forms: Validation, file uploads
- Authentication: Login, sessions, JWT
- Testing: E2E patterns, test helpers
- Production: Deployment, monitoring, scaling
- Patterns: Common UI patterns, best practices
- Use
gofmtfor formatting - Follow Effective Go
- Keep functions focused and small
- Add godoc comments for exported functions
- Issues: GitHub Issues
- Discussions: GitHub Discussions
By contributing, you agree that your contributions will be licensed under the MIT License.