harbor run -t openthoughts/tasktrove-exp-rpt-stack-go-v4-stack-go-7811harbor download openthoughts/tasktrove-exp-rpt-stack-go-v4-stack-go-7811Task Description: Implement IRC Connection Logic
You need to implement the functionality for an IRC connection handler in Go, specifically within the /app/ directory. The main structure to implement is the IRC type and its methods, focusing on the connectivity logic that the provided tests require.
Connect Method: Implement a Connect(server string) method for the IRC type that:
:) that separates the hostname and the port number.Logging Validation: Ensure that if the Log field of the IRC instance is nil, connecting should result in an error.
User and Nick Validation: Ensure that an empty user or nick in the IRC instance also results in an error when attempting to connect.
Callback Mechanism: Implement methods to manage event callbacks:
AddCallback(code string, callback func(*Event)): Adds a callback for specific events.RemoveCallback(code string, id int): Removes a callback by its identifier.ClearCallback(code string): Clears all callbacks for a specific code.RunCallbacks(e *Event): Executes all callbacks associated with a specific event.Setup for Nick Tracking: Implement the ability for the IRC instance to track users in a channel, including:
Unit Test Compliance: Your implementation should make all the provided test cases pass. Pay special attention to error handling and ensure that the conditions outlined in the tests are thoroughly validated.
IRC type and its methods within app/irc.go (or a similar file structure as required).This task requires a good understanding of error handling within Go, as well as the ability to manage goroutines for the callback system while maintaining thread safety for shared data like user lists.
Important: declare your solution in package irc (the test file uses package irc, so the implementation must use the matching package name).