Conversation
…responses
This commit modernizes the codebase to leverage recent Go standard library
improvements and enforces type safety in API responses.
Changes:
- Use slices.DeleteFunc for efficient slice filtering in DeleteKeyFromUser
(replaces manual loop with stdlib function from Go 1.21+)
- Fix incorrect map initialization syntax (maps don't accept capacity parameter)
in handleHTTPGetUsersSSHKeys and handleHTTPGetUserSSHKey
- Replace all map[string]interface{} JSON responses with typed structs
(successResponse, keysResponse, multiUserKeysResponse, keyResponse)
- Improve type safety and enable compile-time checking of API responses
- Maintain backward compatibility - no API changes, only internal improvements
Benefits:
- Better performance with slices.DeleteFunc (optimized stdlib implementation)
- Type safety prevents runtime errors in JSON serialization
- Improved code readability and maintainability
- IDE autocomplete and refactoring support for response types
- Correct Go idioms (maps without capacity parameter)
Testing: All existing tests pass, go vet clean, gofmt compliant
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
…fety
This commit addresses issues missed in the initial modernization pass and
completes the comprehensive analysis from Go 1.19 → 1.25.
Changes:
- Add errorResponse type for auth/authz error responses in auth_middleware.go
- Replace remaining map[string]interface{} in middleware error handlers
- Use errors.Join (Go 1.20) in cmd/serve.go for better UX when reporting
multiple missing required flags - now shows all errors at once instead
of failing one at a time
Analysis completed for Go 1.19 → 1.25:
- Go 1.20: errors.Join ✓, context.WithCancelCause (not applicable)
- Go 1.21: slices.DeleteFunc ✓, min/max/clear/maps/cmp (not applicable)
- Go 1.22-1.25: No applicable features for this codebase
Module updates analyzed:
- Fiber v2.52.9: Bug fixes/performance (no new APIs needed)
- bbolt v1.4.3: Performance improvements (automatic)
- golang.org/x/crypto v0.42.0: No relevant changes to ssh package
- cobra v1.10.1: No new features for simple CLI usage
Benefits:
- Complete type safety across all JSON responses
- Better user experience for missing CLI flags
- Comprehensive Go 1.19+ modernization complete
Testing: All tests pass, go vet clean, gofmt compliant, build successful
🤖 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
This PR comprehensively modernizes the Raybeam codebase to leverage ALL Go improvements from Go 1.19 → 1.25.1 (not just 1.24/1.25 as initially scoped) and enforces complete type safety throughout the API layer. It also analyzes all updated module features for applicable improvements.
Comprehensive Analysis Scope
Go Version Evolution Checked
Module Updates Analyzed
Changes Implemented
1. Use
slices.DeleteFuncfor Efficient Filtering (Go 1.21)internal/models/ssh_key.go:1022. Use
errors.Joinfor Better UX (Go 1.20)cmd/serve.go:71-853. Fix Incorrect Map Initialization
internal/server/route_ssh_key.go:230, 307make(map[...], 0)- maps don't accept capacity parameter4. Complete Type Safety - Replace ALL Untyped JSON
internal/server/route_ssh_key.go,internal/server/auth_middleware.gomap[string]interface{}Features Analyzed But Not Applicable
Go Built-ins/Stdlib
Rationale
This is a simple REST API service with straightforward CRUD operations. Advanced features like context cancellation, iterators, and complex comparisons aren't needed for the current architecture.
Testing
go vet ./...cleangofmtcompliantgo buildsuccessfulPerformance & Quality Impact
slices.DeleteFuncuses optimized stdlib implementationerrors.Joinshows all CLI errors at onceCommits
6565293- Initial modernization (slices, typed routes, map fixes)1c0e814- Complete pass (errors.Join, typed middleware, comprehensive analysis)Verification
All checks pass successfully. Comprehensive Go 1.19 → 1.25 modernization complete.
🤖 Generated with Claude Code