Add solution for Challenge 3 by WHFF521#1889
Conversation
WalkthroughAdds a Go employee/manager domain with slice-backed storage, employee mutation, average salary calculation, ID lookup, and a ChangesEmployee manager implementation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
challenge-3/submissions/WHFF521/solution-template.go (1)
22-32: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider using
slices.DeleteFuncfor an idiomatic in-place removal.The current implementation works perfectly but allocates a new slice. Since Go 1.21, the standard library provides
slices.DeleteFunc, which performs an in-place filter. This approach avoids allocating a new slice while safely zero-clearing tail elements to prevent memory leaks.// Add "slices" to your imports at the top of the file: import ( "fmt" "slices" )♻️ Proposed refactor
// RemoveEmployee removes an employee by ID from the manager's list. func (m *Manager) RemoveEmployee(id int) { // TODO: Implement this method - var result []Employee - for _,e :=range(m.Employees){ - if e.ID!=id{ - result = append(result,e) - } - } - m.Employees = result + m.Employees = slices.DeleteFunc(m.Employees, func(e Employee) bool { + return e.ID == id + }) }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d7a18d9d-5607-43d4-9dd8-3c127a7f51a4
📒 Files selected for processing (1)
challenge-3/submissions/WHFF521/solution-template.go
|
🎉 Auto-merged! This PR was automatically merged after 2 days with all checks passing. Thank you for your contribution, @WHFF521! 📊 Scoreboards and badges will be updated shortly. |
Challenge 3 Solution
Submitted by: @WHFF521
Challenge: Challenge 3
Description
This PR contains my solution for Challenge 3.
Changes
challenge-3/submissions/WHFF521/solution-template.goTesting
Thank you for reviewing my submission! 🚀