Skip to content
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

refactor: separate port and address in Server struct for flexibility #13

Merged
merged 3 commits into from
Sep 20, 2024

Conversation

gabrielluizsf
Copy link
Contributor

  • Added port field to Server struct to store the port separately from addr.
  • Modified NewServer to initialize the port field instead of setting addr directly.
  • Introduced setAddr method to handle address formatting based on port, with a fallback to port 0 if unspecified.
  • Improved readability and separation of concerns by distinguishing port from the full address.

- Added `port` field to `Server` struct to store the port separately from `addr`.
- Modified `NewServer` to initialize the `port` field instead of setting `addr` directly.
- Introduced `setAddr` method to handle address formatting based on port, with a fallback to port `0` if unspecified.
- Improved readability and separation of concerns by distinguishing port from the full address.
- adding a return statement to ensure that if s.port is empty, the method exits early without modifying s.addr. This improves the logic by preventing unnecessary assignments and enhances code readability.
…ogic

- implemented a unit test for the setAddr method to ensure it correctly handles both cases: when a valid port is provided and when the port is empty. This prevents future regressions by confirming that s.addr is only modified as intended.
@i9si i9si merged commit 84af447 into i9si-sistemas:main Sep 20, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants