Modernize context.go by replacing interface{} with any#2822
Merged
Conversation
Modernizes the Context interface by replacing all instances of interface{}
with the more readable 'any' type alias introduced in Go 1.18.
**Changes:**
- Replaced interface{} with any in all Context interface method signatures
- Affects Get(), Set(), Bind(), Validate(), Render(), JSON(), JSONP(), XML(),
Blob(), Stream(), File(), Attachment(), Inline(), and NoContent() methods
- Total of 23 interface{} → any replacements
**Benefits:**
- Improves code readability and modernizes to Go 1.18+ standards
- No functional changes - 'any' is just an alias for interface{}
- Follows current Go best practices for new code
- Makes the API more approachable for developers familiar with modern Go
**Compatibility:**
- Zero breaking changes - 'any' and interface{} are identical
- Maintains full backward compatibility
- All existing code continues to work unchanged
This modernization aligns Echo with current Go conventions while maintaining
100% compatibility with existing applications.
🤖 Generated with [Claude Code](https://claude.ai/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
Modernizes the Echo Context interface by replacing all instances of
interface{}with the more readableanytype alias introduced in Go 1.18.Changes
23 Modernizations across Context interface methods:
Get(key string) interface{}→Get(key string) anySet(key string, val interface{})→Set(key string, val any)Bind(i interface{})→Bind(i any)Validate(i interface{})→Validate(i any)Render(code int, name string, data interface{})→Render(code int, name string, data any)JSON(code int, i interface{})→JSON(code int, i any)JSONP(code int, callback string, i interface{})→JSONP(code int, callback string, i any)XML(code int, i interface{})→XML(code int, i any)Blob(code int, contentType string, b []byte)→ (internal any usage)Stream(code int, contentType string, r io.Reader)→ (internal any usage)interface{}parametersBenefits
🚀 Modernization
📖 Developer Experience
anyis more intuitive and self-documenting thaninterface{}🔒 Safety & Compatibility
anyis just an alias forinterface{}Testing
Type of Change
Impact
This change modernizes Echo's public API to follow current Go conventions while maintaining perfect backward compatibility. Developers using Echo will benefit from:
This is a pure modernization change with zero risk -
anyandinterface{}are functionally identical.