-
-
Couldn't load subscription status.
- Fork 658
Add solution for Challenge 2 by AlexandrZlnov #620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds three Go submission programs: challenge-1 adds Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Main as main (challenge-2)
participant Reverse as ReverseString
User->>Main: provide input line (stdin)
Main->>Reverse: ReverseString(input) -- uses []rune swap
Reverse-->>Main: reversed string
Main-->>User: print reversed string (stdout)
sequenceDiagram
participant User
participant Main as main (challenge-1)
participant Sum as Sum
User->>Main: provide "int, int" (stdin)
Main->>Sum: Sum(a, b)
Sum-->>Main: a + b
Main-->>User: print sum (stdout)
sequenceDiagram
participant Caller
participant Manager
Caller->>Manager: AddEmployee(e)
Manager-->>Manager: append employee
Caller->>Manager: RemoveEmployee(id)
Manager-->>Manager: find index, slices.Delete(...)
Caller->>Manager: GetAverageSalary()
Manager-->>Manager: sum salaries / count (returns 0 if none)
Manager-->>Caller: average (float64)
Caller->>Manager: FindEmployeeByID(id)
Manager-->>Caller: *Employee or nil
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Pre-merge checks❌ Failed checks (2 warnings, 1 inconclusive)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
challenge-2/submissions/AlexandrZlnov/solution-template.go (1)
9-21: Add error handling for scanner.The scanner may encounter errors during input reading that won't be detected. After the scan loop, check for errors to ensure robust I/O handling.
Apply this diff to add error handling:
func main() { // Read input from standard input scanner := bufio.NewScanner(os.Stdin) if scanner.Scan() { input := scanner.Text() // Call the ReverseString function output := ReverseString(input) // Print the result fmt.Println(output) } + if err := scanner.Err(); err != nil { + fmt.Fprintf(os.Stderr, "Error reading input: %v\n", err) + os.Exit(1) + } }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
challenge-1/submissions/AlexandrZlnov/solution-template.go (1)
7-19: Logic is correct; consider stderr for errors.The main function correctly reads input, handles errors, and produces output. For better practice, error messages could be written to stderr using
fmt.Fprintln(os.Stderr, ...)and the program could exit with a non-zero status.Optional improvement:
+import ( + "fmt" + "os" +) + func main() { var a, b int // Read two integers from standard input _, err := fmt.Scanf("%d, %d", &a, &b) if err != nil { - fmt.Println("Error reading input:", err) - return + fmt.Fprintln(os.Stderr, "Error reading input:", err) + os.Exit(1) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
challenge-1/submissions/AlexandrZlnov/solution-template.go(1 hunks)
🔇 Additional comments (1)
challenge-1/submissions/AlexandrZlnov/solution-template.go (1)
1-5: LGTM!Package declaration and imports are appropriate for this solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (1)
challenge-3/submissions/AlexandrZlnov/solution-template.go (1)
3-6: Minor formatting inconsistency.Extra whitespace before the closing parenthesis on line 6.
import ( "fmt" "slices" - ) +)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
challenge-3/submissions/AlexandrZlnov/solution-template.go(1 hunks)
🔇 Additional comments (2)
challenge-3/submissions/AlexandrZlnov/solution-template.go (2)
8-17: LGTM!The struct definitions are clean and well-structured for an employee management system.
70-82: Demo logic is sound.The main function appropriately demonstrates the Manager's methods. Once the critical issues in
GetAverageSalaryandFindEmployeeByIDare resolved, this will work correctly.
No description provided.