Comments (3)
Likewise getHostPosition
getHostPosition
and getHostnamePosition
need plural versions
from cli.
good find!
from cli.
I notice that in places in the code it uses this and then loops until no instances are found, and in other places it might not do this.
Instead, if it fetched all positions, sorted them from smallest to largest, then worked backwards from the end of the file to the start, we can achieve the same result using these functions. I did start on adding the functions which seemed easy enough, but didn't look into using them, golang isn't super familiar to me. Something like this is what I was thinking:
func (h Hosts) getIpPositions(ip string) []int {
positions := new [...]int
for i := range h.Lines {
line := h.Lines[i]
if !line.IsComment() && line.Raw != "" && line.IP == ip {
append(positions, i)
}
}
return positions
}
from cli.
Related Issues (19)
- Create Backup Cmd
- Goodhosts don't remove duplicates HOT 10
- Goodhosts issues on OSX HOT 9
- Add a version subcommand or parameter HOT 1
- Goodhosts check requires a writable hosts file HOT 2
- Create Restore Cmd
- clean and check shortened subcommands are the same HOT 1
- More clean options HOT 3
- readme not updated with 1.0.6-1.0.7 HOT 2
- Goodhosts' rewrite of the hosts file renders MAMP incapable of managing its entries HOT 30
- goodhosts stalls when the /etc/hosts file has too many entries HOT 3
- Install cli with brew? HOT 1
- Breaks Windows hosts file line length rules HOT 3
- Windows maximum aliases per line HOT 3
- Crosspost: https://github.com/goodhosts/hostsfile/issues/39 HOT 1
- Q: Maintenance HOT 16
- Bug: Comment detection on host line is missing HOT 3
- Fix BOM HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cli.