Skip to content

refactor: update to use Must(New()) pattern for livetemplate v0.3.0#2

Merged
adnaan merged 5 commits intomainfrom
refactor/use-must-new-pattern
Nov 12, 2025
Merged

refactor: update to use Must(New()) pattern for livetemplate v0.3.0#2
adnaan merged 5 commits intomainfrom
refactor/use-must-new-pattern

Conversation

@adnaan
Copy link
Copy Markdown
Contributor

@adnaan adnaan commented Nov 12, 2025

Summary

Updates all examples to use the new Must(New()) pattern introduced in livetemplate v0.3.0.

Changes

  • Updated all 9 example applications to use Must(New()) instead of bare New()
  • Removed local replace directives from go.mod files
  • Ready to upgrade to livetemplate v0.3.0 once released

Affected Examples

  • avatar-upload
  • chat
  • counter
  • graceful-shutdown
  • observability
  • production/single-host
  • testing/01_basic
  • todos
  • trace-correlation

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

adnaan and others added 2 commits November 12, 2025 08:19
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>
Copilot AI review requested due to automatic review settings November 12, 2025 18:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with livetemplate.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.

adnaan and others added 3 commits November 12, 2025 19:16
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>
@adnaan adnaan merged commit b976439 into main Nov 12, 2025
9 checks passed
@adnaan adnaan deleted the refactor/use-must-new-pattern branch November 12, 2025 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants