[PR #16] [MERGED] Unbundle clean operations and refactor RemoveByHostname #28

Closed
opened 2026-03-02 05:08:14 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/goodhosts/hostsfile/pull/16
Author: @tomjn
Created: 1/18/2021
Status: Merged
Merged: 1/18/2021
Merged by: @luthermonson

Base: masterHead: patch-1


📝 Commits (6)

  • 1dd5b37 Unbundle clean operations and refactor RemoveByHostname
  • 5ddf021 Fix CI issues in hosts.go
  • a03a232 refactor removeFromSlice to remove all instances, and add a test
  • ac6d725 fix error message wording when teesting RemoveByHostname
  • 7d75b5f fix RemoveByHostname
  • 4142246 fix whitespace issue in utils test

📊 Changes

4 files changed (+63 additions, -18 deletions)

View changed files

📝 hosts.go (+26 -13)
📝 hosts_test.go (+2 -1)
📝 utils.go (+13 -4)
📝 utils_test.go (+22 -0)

📄 Description

This does the following:

  • if a hosts line has a single host then hostname removal does not occur, even if that single host is the one we want to eliminate
  • there's no reason to loop through the whole slice multiple times looking for a position, just do it once, and create a new slice as we iterate
  • it's now possible to de-dupe hosts without sorting in a single step which should make more specific --clean parameters in the cli package easier to implement

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/goodhosts/hostsfile/pull/16 **Author:** [@tomjn](https://github.com/tomjn) **Created:** 1/18/2021 **Status:** ✅ Merged **Merged:** 1/18/2021 **Merged by:** [@luthermonson](https://github.com/luthermonson) **Base:** `master` ← **Head:** `patch-1` --- ### 📝 Commits (6) - [`1dd5b37`](https://github.com/goodhosts/hostsfile/commit/1dd5b37be3efd186952bdcfa7c2d4813a66e4b1f) Unbundle clean operations and refactor RemoveByHostname - [`5ddf021`](https://github.com/goodhosts/hostsfile/commit/5ddf021d33af7aa71336aadc7deeecc2d5c70cd4) Fix CI issues in hosts.go - [`a03a232`](https://github.com/goodhosts/hostsfile/commit/a03a232384d5149bd2bbafbbe95dafe64d70fac3) refactor removeFromSlice to remove all instances, and add a test - [`ac6d725`](https://github.com/goodhosts/hostsfile/commit/ac6d7256ce5d5f8e0070ab8fded908beed3c89b8) fix error message wording when teesting RemoveByHostname - [`7d75b5f`](https://github.com/goodhosts/hostsfile/commit/7d75b5f26e91352281d917a3792373c6cb1c52fb) fix RemoveByHostname - [`4142246`](https://github.com/goodhosts/hostsfile/commit/4142246dfdda1232e9f465cac5ce2ed3a87140cc) fix whitespace issue in utils test ### 📊 Changes **4 files changed** (+63 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `hosts.go` (+26 -13) 📝 `hosts_test.go` (+2 -1) 📝 `utils.go` (+13 -4) 📝 `utils_test.go` (+22 -0) </details> ### 📄 Description This does the following: - if a hosts line has a single host then hostname removal does not occur, even if that single host is the one we want to eliminate - there's no reason to loop through the whole slice multiple times looking for a position, just do it once, and create a new slice as we iterate - it's now possible to de-dupe hosts without sorting in a single step which should make more specific --clean parameters in the cli package easier to implement --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 05:08:14 +03:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hostsfile#28
No description provided.