-
Notifications
You must be signed in to change notification settings - Fork 12
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
HostsPerLine is destructive #40
Comments
The issue seems to be in goodhosts/cli project. With or without "--clean" flag, cli is performing clean process. See Issue Comment The cli project seems to be handling bool value incorrectly. Explicitly setting default bool value may help. |
Note that I cannot reproduce this on MacOS, this is very likely Windows related. We need to confirm what the command is doing to the hosts file in addition to stripping out comments to eliminate options, my current theory is that this has nothing to do with the clean parameters, but due to the attempt to workaround a Windows bug where more than 8 hosts on a line breaks the hosts file. We can confirm this if we had examples that can be used to see if it's sorting the hosts file, merging lines that were previously separate, etc |
@luthermonson is it possible that this is all because of the Ip de-duplication at the top of that function? func (h *Hosts) HostsPerLine(count int) {
// restacks everything into 1 ip again so we can do the split, do this even if count is -1 so it can reset the slice
h.RemoveDuplicateIps() |
For context @jd4u is reporting that comments were stripped from their hosts file on use regardless of wether the clean parameter was specified or not. They're a WIndows user so |
Yes @tomjn, you may be pointing right place.
|
Just for note,
|
Comments are stripped regardless of the cli. This is easy to demonstrate with https://github.com/rfay/goodhostsbug |
One improvement here would be to respect "important" standard lines like "localhost". A longer-term improvement would be to add separate lines for goodhosts-managed lines (probably marked with a comment before and after). |
I've seen some good maintenance going on in this area lately, thanks! Has this one been addressed yet? |
ya all that stuff got refactored to index the lookup hashmaps better. i bet your example repo works against latest main, give it a check and report back findings and ill fix if still broke |
No, it still makes a pretty big mess. Comments are mostly destroyed and misplaced. I updated https://github.com/rfay/goodhostsbug and its readme to show more how to demonstrate it. Bottom line is that
gets transformed to
|
im sorry i wasted your time... I forgot I hadn't released the changes here #46 please try with v0.1.4 as with a test off latest main i got the following...
|
Yay, it's working great! This issue can be closed (at least about the comments), thanks so much! |
My pleasure! Glad it's working |
Thanks so much for your maintenance of this! Reopened |
The
HostsPerLine
function is destructive, and does a number of unexpected things:I believe this is related to goodhosts/vagrant#51
The text was updated successfully, but these errors were encountered: