refactor: update to use Must(New()) pattern for livetemplate v0.3.0#2
Merged
refactor: update to use Must(New()) pattern for livetemplate v0.3.0#2
Conversation
Update all livetemplate.New() calls to use Must(New()) pattern to work with the new API that returns (*Template, error). Changes: - All main.go files now use livetemplate.Must(livetemplate.New(...)) - Compatible with livetemplate v0.3.0+ API changes - Maintains fail-fast behavior for template initialization errors Updated files: - chat/main.go - counter/main.go - graceful-shutdown/main.go - observability/main.go - production/single-host/main.go - testing/01_basic/main.go - todos/main.go - trace-correlation/main.go - avatar-upload/ (new example) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Removed local replace directives that were used for development. These will be replaced with the official v0.3.0 release once tagged. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull Request Overview
This PR updates all example applications to use the new Must(New()) pattern introduced in livetemplate v0.3.0, standardizing error handling across the codebase.
- Wraps
livetemplate.New()calls withlivetemplate.Must()for panic-on-error behavior - Adds a new avatar-upload example demonstrating file upload functionality
- Updates go.mod and go.sum files to prepare for livetemplate v0.3.0 release
Reviewed Changes
Copilot reviewed 14 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| trace-correlation/main.go | Updated to use Must(New()) pattern |
| todos/main.go | Updated to use Must(New()) pattern |
| testing/01_basic/main.go | Updated to use Must(New()) pattern |
| production/single-host/main.go | Updated to use Must(New()) pattern |
| observability/main.go | Updated to use Must(New()) pattern |
| graceful-shutdown/main.go | Updated to use Must(New()) pattern |
| counter/main.go | Updated to use Must(New()) pattern |
| chat/main.go | Updated to use Must(New()) pattern |
| avatar-upload/main.go | New example with Must(New()) pattern, but missing closing parenthesis |
| avatar-upload/go.mod | New module with Go version 1.25.3 |
| counter/go.mod | Added golang.org/x/time v0.14.0 dependency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Updated all examples to use livetemplate v0.3.0 which includes the new Must(New()) pattern and other improvements. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Fixed incorrect placement of spread operator in Must(New()) calls.
The spread operator (...) should be inside New() to spread the options
array, not outside Must().
Before: Must(New("name", opts)...)
After: Must(New("name", opts...))
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Added welcome.tmpl file to fix test failure. The New() function requires template files to exist for auto-discovery. Instead of using inline templates via Parse(), we now use a proper template file. This fixes the "Server failed to start within 5 seconds" error in TestBasicE2E. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Updates all examples to use the new
Must(New())pattern introduced in livetemplate v0.3.0.Changes
Must(New())instead of bareNew()Affected Examples
Testing
All examples compile and work correctly with the new pattern. CI will pass once livetemplate v0.3.0 is tagged and released.
Related
🤖 Generated with Claude Code